From e3802df79b5b69c8b6feb620b29cfa60db144fbc Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Mon, 6 Feb 2023 21:09:31 +0100 Subject: [PATCH] Update Implementation Methode AIGridGUI --- src/main/java/BattleShip/AIGridGUI.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index cb1b9a4..b017b6c 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -64,7 +64,25 @@ public class AIGridGUI extends JPanel { allShips.add(battleship); allShips.add(aircraftCarrier); + //Add all directions to an ArrayList to allow for comparing and sorting directions. + directions.add(up); + directions.add(down); + directions.add(right); + directions.add(left); + //Make grid that consists of r rows and c columns of buttons. + + GridLayout g = new GridLayout(rows,columns); + this.setLayout(g); + + for(int i = 0; i < (rows * columns); i++) { + BSButton b = new BSButton(); + b.setGridLocation(i); + buttons.add(b); + this.add(b); + } + + defaultBorder = buttons.get(0).getBorder(); } }