From 350462421e9589f955441f60477301b4278c96dd Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Tue, 7 Feb 2023 02:39:16 +0100 Subject: [PATCH] Update Implementation AIGridGUI class --- src/main/java/BattleShip/AIGridGUI.java | 29 +++++++++++++++++++++- target/classes/BattleShip/AIGridGUI.class | Bin 9291 -> 10055 bytes 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/java/BattleShip/AIGridGUI.java b/src/main/java/BattleShip/AIGridGUI.java index 0af94b9..dcb864b 100644 --- a/src/main/java/BattleShip/AIGridGUI.java +++ b/src/main/java/BattleShip/AIGridGUI.java @@ -26,7 +26,10 @@ public class AIGridGUI extends JPanel { int f; // it is the first Color Red = new Color(100, 0, 0); // Border loweredBevel = BorderFactory.createLoweredBevelBorder(); + Border raisedbevel = BorderFactory.createRaisedBevelBorder(); Border defaultBorder; + //empty = BorderFactory.createEmptyBorder(4, 4, 4, 4); + Border compound = BorderFactory.createCompoundBorder(); Ship shipToPlace; boolean vertical = false; boolean clear; @@ -499,7 +502,7 @@ public class AIGridGUI extends JPanel { public void highlightCells(BSButton b, int x) { BSButton cell = b; - int actionToTake = x; + int action = x; clear = true; //Check whether sufficient spaces are clear to place the ship. @@ -511,5 +514,29 @@ public class AIGridGUI extends JPanel { } } } + + if(clear) { + if(vertical) { + + for(int i = 0; i < shipToPlace.getLength(); i++) { + BSButton bsb = buttons.get(cell.getGridLocation() + (i * columns)); + //If mouse entered, highlight cells via lowered bevel. + if(action == 1) { + bsb.setBorder(raisedbevel); + } else { + //If mouse released, place ship and color ship cells. + if(action == 2) { + bsb.setCellContents(shipToPlace); + bsb.setBackground(Color.gray); + bsb.setBorder(raisedbevel); + } else { + //If mouse exited, unhighlight cells. + bsb.setBorder(compound); + } + } + } + } + } } + } diff --git a/target/classes/BattleShip/AIGridGUI.class b/target/classes/BattleShip/AIGridGUI.class index 5cba1940b6fdddb930a50d7a13ea07accf960d52..487df6c0615f20130b48fcd178b7409992e0ea4b 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