diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index 8edf0cf..f825fc6 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -39,6 +39,25 @@ public class GridGUI extends JPanel { allShips.add(submarine); allShips.add(battleship); 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() {