blob: cb6c6cafd17e983f1c9a457a3052ce4b89a467b3 (
plain) (
blame)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
package ui;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import models.CONSTS;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Color;
import javax.swing.JButton;
import javax.swing.JTextArea;
import java.awt.Font;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.awt.BorderLayout;
public class MainFrame extends JFrame implements Runnable {
public static void main(String[] args) {
MainFrame frame = new MainFrame();
frame.setVisible(true);
}
public ByteBuffer readBuffer=ByteBuffer.allocate(1024);
public SocketChannel client;
public LoginPanel loginPanel=null;
public ChooseOpponentPanel chooseOpponentPanel=null;
GamePanel gamePanel=null;
public long userId=-1;
public MainFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 727, 429);
loginPanel=new LoginPanel();
chooseOpponentPanel=new ChooseOpponentPanel();
gamePanel=new GamePanel();
getContentPane().setLayout(new BorderLayout(0, 0));
add(loginPanel,BorderLayout.CENTER);
setVisible(true);
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e)
{
System.out.println("EXITED");
try {
client.close();
Thread.sleep(500);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.exit(EXIT_ON_CLOSE);
}
});
try {
client=SocketChannel.open(new InetSocketAddress(CONSTS.socketPort));
} catch (IOException e) {
e.printStackTrace();
}
new Thread(this).start();
}
@Override
public void run() {
while(true) {
}
}
public SocketChannel getClient() {
return client;
}
public void setClient(SocketChannel client) {
this.client = client;
}
public LoginPanel getLoginPanel() {
return loginPanel;
}
public void setLoginPanel(LoginPanel loginPanel) {
this.loginPanel = loginPanel;
}
public ChooseOpponentPanel getChooseOpponentPanel() {
return chooseOpponentPanel;
}
public void setChooseOpponentPanel(ChooseOpponentPanel chooseOpponentPanel) {
this.chooseOpponentPanel = chooseOpponentPanel;
}
public GamePanel getGamePanel() {
return gamePanel;
}
public void setGamePanel(GamePanel gamePanel) {
this.gamePanel = gamePanel;
}
public ByteBuffer getReadBuffer() {
return readBuffer;
}
public void setReadBuffer(ByteBuffer readBuffer) {
this.readBuffer = readBuffer;
}
public long getUserId() {
return userId;
}
public void setUserId(long userId) {
this.userId = userId;
}
}
|