-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFrame.java
74 lines (74 loc) · 2.04 KB
/
Frame.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame implements WindowListener, ActionListener
{
Container pane;
JPanel panel;
JFrame frame;
JButton[][] tile;
JLabel label;
Frame(String playerN, boolean wait)
{
frame = new JFrame(playerN);
pane = frame.getContentPane();
label = new JLabel("", SwingConstants.CENTER);
label.setSize(10, 100);
panel = new JPanel();
pane.setLayout(new BorderLayout());
pane.add(label, BorderLayout.NORTH);
pane.add(panel, BorderLayout.SOUTH);
frame.addWindowListener(this);
panel.setLayout(new GridLayout(3,3));
frame.setSize(400,400);
if(!wait)
{
this.label.setText("Connecting To The Server");
this.frame.add(label);
//this.setUpTile();
}
else
{
this.label.setText("Waiting For Other Player");
this.frame.add(label);
}
this.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.frame.setVisible(true);
}
protected void setUpTile()
{
//System.out.println("Super Called!");
this.label.setText("Connected");
this.tile = new JButton[3][3];
for(int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
this.tile[i][j] = new JButton(new ImageIcon("O.png"));
this.tile[i][j].setPreferredSize(new Dimension(100, 100));
this.tile[i][j].addActionListener(this);
this.tile[i][j].putClientProperty("row", i);
this.tile[i][j].putClientProperty("column", j);
this.panel.add(tile[i][j]);
}
}
this.frame.setVisible(true);
}
protected void setLabel(String text)
{
this.label.setText(text);
}
public void actionPerformed(ActionEvent ae){}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
public void windowOpened(WindowEvent arg0) {}
public void windowClosing(WindowEvent arg0)
{
System.out.println("Closing..");
this.frame.dispose();
System.exit(0);
}
}