Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
102 lines (89 loc) · 3.04 KB

File metadata and controls

102 lines (89 loc) · 3.04 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
// JavaChatClientMain.java
// Java Client 시작import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class JavaChatClientMain extends JFrame {
private JPanel contentPane;
private JTextField txtUserName;
private JTextField txtIpAddress;
private JTextField txtPortNumber;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
JavaChatClientMain frame = new JavaChatClientMain();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public JavaChatClientMain() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 254, 321);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel("User Name");
lblNewLabel.setBounds(12, 39, 82, 33);
contentPane.add(lblNewLabel);
txtUserName = new JTextField();
txtUserName.setHorizontalAlignment(SwingConstants.CENTER);
txtUserName.setBounds(101, 39, 116, 33);
contentPane.add(txtUserName);
txtUserName.setColumns(10);
JLabel lblIpAddress = new JLabel("IP Address");
lblIpAddress.setBounds(12, 100, 82, 33);
contentPane.add(lblIpAddress);
txtIpAddress = new JTextField();
txtIpAddress.setHorizontalAlignment(SwingConstants.CENTER);
txtIpAddress.setText("127.0.0.1");
txtIpAddress.setColumns(10);
txtIpAddress.setBounds(101, 100, 116, 33);
contentPane.add(txtIpAddress);
JLabel lblPortNumber = new JLabel("Port Number");
lblPortNumber.setBounds(12, 163, 82, 33);
contentPane.add(lblPortNumber);
txtPortNumber = new JTextField();
txtPortNumber.setText("30000");
txtPortNumber.setHorizontalAlignment(SwingConstants.CENTER);
txtPortNumber.setColumns(10);
txtPortNumber.setBounds(101, 163, 116, 33);
contentPane.add(txtPortNumber);
JButton btnConnect = new JButton("Connect");
btnConnect.setBounds(12, 223, 205, 38);
contentPane.add(btnConnect);
Myaction action = new Myaction();
btnConnect.addActionListener(action);
txtUserName.addActionListener(action);
txtIpAddress.addActionListener(action);
txtPortNumber.addActionListener(action);
}
class Myaction implements ActionListener // 내부클래스로 액션 이벤트 처리 클래스
{
@Override
public void actionPerformed(ActionEvent e) {
String username = txtUserName.getText().trim();
String ip_addr = txtIpAddress.getText().trim();
String port_no = txtPortNumber.getText().trim();
JavaChatClientView view = new JavaChatClientView(username, ip_addr, port_no);
setVisible(false);
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.