From 1d3e62cbe1d3077913b89233391fc3b470a5c9d1 Mon Sep 17 00:00:00 2001 From: Thoumi Ngonga Brice Date: Wed, 8 Feb 2023 16:02:15 +0100 Subject: [PATCH] Update Methode void BuildGui and class NewGameListener --- src/main/java/BattleShip/BShip.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/BattleShip/BShip.java b/src/main/java/BattleShip/BShip.java index 6b9054c..7542315 100644 --- a/src/main/java/BattleShip/BShip.java +++ b/src/main/java/BattleShip/BShip.java @@ -1,6 +1,7 @@ package BattleShip; import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -8,6 +9,9 @@ public class BShip { public GridGUI grid1; JPanel thePanel = new JPanel(); + JPanel textPanel = new JPanel(); + JTextArea textArea = new JTextArea(); + JMenuItem auto; JMenuItem[] boardSize = new JMenuItem[3]; public AIGridGUI grid2; int rows = 10; @@ -46,6 +50,22 @@ public class BShip { boardSize[i].addActionListener(new NewGameListener()); sizes.add(boardSize[i]); } + auto = new JMenuItem("Auto Place Ships"); + auto.addActionListener(new NewGameListener()); + auto.setEnabled(true); + menu.add(newGame); + menu.add(sizes); + menu.add(auto); + bar.add(menu); + + //Setup text area between grids to show game status. + + textArea.setText(""); + textPanel.setBackground(new Color(36,37,38)); + textPanel.setMaximumSize(new Dimension(700, 10)); + textPanel.add(textArea); + thePanel.add(textPanel); + } public class NewGameListener implements ActionListener {