|
@ -1,6 +1,7 @@ |
|
|
package BattleShip; |
|
|
package BattleShip; |
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
import javax.swing.*; |
|
|
|
|
|
import java.awt.*; |
|
|
import java.awt.event.ActionEvent; |
|
|
import java.awt.event.ActionEvent; |
|
|
import java.awt.event.ActionListener; |
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
@ -8,6 +9,9 @@ public class BShip { |
|
|
|
|
|
|
|
|
public GridGUI grid1; |
|
|
public GridGUI grid1; |
|
|
JPanel thePanel = new JPanel(); |
|
|
JPanel thePanel = new JPanel(); |
|
|
|
|
|
JPanel textPanel = new JPanel(); |
|
|
|
|
|
JTextArea textArea = new JTextArea(); |
|
|
|
|
|
JMenuItem auto; |
|
|
JMenuItem[] boardSize = new JMenuItem[3]; |
|
|
JMenuItem[] boardSize = new JMenuItem[3]; |
|
|
public AIGridGUI grid2; |
|
|
public AIGridGUI grid2; |
|
|
int rows = 10; |
|
|
int rows = 10; |
|
@ -46,6 +50,22 @@ public class BShip { |
|
|
boardSize[i].addActionListener(new NewGameListener()); |
|
|
boardSize[i].addActionListener(new NewGameListener()); |
|
|
sizes.add(boardSize[i]); |
|
|
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 { |
|
|
public class NewGameListener implements ActionListener { |
|
|