Browse Source

Update Methode void BuildGui and class NewGameListener

main
Thoumi Ngonga Brice 2 years ago
parent
commit
1d3e62cbe1
  1. 20
      src/main/java/BattleShip/BShip.java

20
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 {

Loading…
Cancel
Save