package tictactoe; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class UserGUI implements UserInterface, ActionListener { private GameInterface game; private JFrame frame; private JPanel tttPanel; private boolean firstDisplay = true; private JLabel topLabel; // private JLabel bottomLabel; private JButton[][] buttons; private String waitingMsg = " Waiting for the other player to move ..."; public UserGUI(GameInterface game) { System.out.println("Creating new UserGUI"); this.game = game; frame = new JFrame("Tic Tac Toe"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); tttPanel = new JPanel(); tttPanel.setLayout(new BorderLayout()); topLabel = new JLabel(waitingMsg); tttPanel.add(topLabel,BorderLayout.NORTH); // bottomLabel = new JLabel("This is also a test"); // tttPanel.add(bottomLabel,BorderLayout.SOUTH); frame.getContentPane().add(tttPanel); // component added to content pane game.joinGame(this); //frame.pack(); // sets the frame's size to accommodate its components //frame.setVisible(true); // displays the frame } public void setId(char id){ frame.setTitle("Tic Tac Toe for user "+id); if (id =='O') frame.setLocation(400,0); } public void boardChanged(char[][] board) { if (firstDisplay) { System.out.println("Setting up buttons"); setupButtons(board.length); frame.setVisible(true); firstDisplay = false; } for (int i=0;i