From 02356f36d60b527eeef4cdf794bafc2935efc259 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 22:19:39 +0100 Subject: [PATCH] update --- src/main/java/BattleShip/GridGUI.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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() {