import javax swing import java awt public class JmsChat extends JFrame

 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
import javax.swing.*;
import java.awt.*;
public class JmsChat extends JFrame {
private JFrame frame;
private JTextArea textAreaChat;
private JTextArea textAreaInput;
private JTextField textField;
private JPanel buttonsPanel;
private JPanel textPanel;
private JPanel nickNamePanel;
private JButton send;
private JLabel textLabel;
public JmsChat(){
super("Jms Test Chat");
setDefaultCloseOperation(EXIT_ON_CLOSE);
frame = new JFrame();
textPanel = new JPanel(new BorderLayout());
nickNamePanel = new JPanel(new BorderLayout());
textAreaChat = new JTextArea(10,20);
textAreaChat.setEditable(false);
textLabel = new JLabel("Input your message here");
textAreaInput = new JTextArea(10,20);
textAreaInput.setEditable(true);
textField = new JTextField("",20);
textPanel.add(textAreaChat, BorderLayout.NORTH);//add text AREA
textPanel.add(textLabel, BorderLayout.CENTER);
textPanel.add(textAreaInput,BorderLayout.SOUTH);//add text AREA input
nickNamePanel.add(textField,BorderLayout.EAST);//add text FIELD
buttonsPanel = new JPanel(new BorderLayout());
send = new JButton("send");
buttonsPanel.add(send,BorderLayout.SOUTH);//add button SEND
/* Расставляем компоненты по местам */
add(textPanel, BorderLayout.CENTER);
add(buttonsPanel, BorderLayout.SOUTH);
add(nickNamePanel, BorderLayout.EAST);
// add(textPanel,BorderLayout.CENTER);
}
public static void main(String[] args) {
JmsChat app = new JmsChat();
app.setVisible(true);
app.pack(); /* Эта команда подбирает оптимальный размер в зависимости от содержимого окна */
}
}