Browse Source

update

main
fdai4581 2 years ago
parent
commit
02356f36d6
  1. 19
      src/main/java/BattleShip/GridGUI.java

19
src/main/java/BattleShip/GridGUI.java

@ -39,6 +39,25 @@ public class GridGUI extends JPanel {
allShips.add(submarine); allShips.add(submarine);
allShips.add(battleship); allShips.add(battleship);
allShips.add(aircraftCarrier); allShips.add(aircraftCarrier);
for(int i = 1; i < (rows * columns); i++) {
BSButton b = new BSButton();
b.setEnabled(false);
b.setGridLocation(i);
buttons.add(b);
}
setShipLocations();
GridLayout g = new GridLayout(rows,columns);
this.setLayout(g);
//Add listeners to all cells in grid to listen for guesses.
for (BSButton bsb : buttons) {
bsb.addActionListener(new MyCellListener());
this.add(bsb);
}
} }
public void setShipLocations() { public void setShipLocations() {

Loading…
Cancel
Save