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 5cba194..487df6c 100644 Binary files a/target/classes/BattleShip/AIGridGUI.class and b/target/classes/BattleShip/AIGridGUI.class differ