Browse Source

Refratoring (add new Methode)

main
Thoumi Ngonga Brice 2 years ago
parent
commit
3dc521082c
  1. 21
      src/main/java/BattleShip/AIGridGUI.java

21
src/main/java/BattleShip/AIGridGUI.java

@ -26,7 +26,7 @@ public class AIGridGUI extends JPanel {
int firstHit;
Color darkRed = new Color(100, 0, 0); //
Border loweredBevel = BorderFactory.createLoweredBevelBorder();
Border raisedbevel = BorderFactory.createRaisedBevelBorder();
//Border raisedbevel = BorderFactory.createRaisedBevelBorder();
Border defaultBorder;
//empty = BorderFactory.createEmptyBorder(4, 4, 4, 4);
Border compound = BorderFactory.createCompoundBorder();
@ -535,6 +535,25 @@ public class AIGridGUI extends JPanel {
}
}
}
}else {
for(int i = 0; i < shipToPlace.getLength(); i++) {
BSButton bsb = buttons.get(cell.getGridLocation() + i);
if(action == 0) {
//If mouse entered, highlight cells via lowered bevel.
bsb.setBorder(loweredBevel);
} else {
//If mouse released, place ship and color ship cells.
if(action == 1) {
bsb.setCellContents(shipToPlace);
bsb.setBackground(Color.blue);
bsb.setBorder(loweredBevel);
} else {
//If mouse exited, unhighlight cells.
bsb.setBorder(defaultBorder);
}
}
}
}
}
}

Loading…
Cancel
Save