-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatWindow.java
77 lines (59 loc) · 2.29 KB
/
ChatWindow.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
75
76
77
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class ChatWindow extends JFrame {
private static final long serialVersionUID = 1L;
public void chatWindow(){
setSize(590,500);
setVisible(true);
Container content = getContentPane();
content.setLayout(null);
content.setBackground(Color.orange);
JLabel Title = new JLabel("Welcome to Chat Master");
Font currentFont = Title.getFont();
Title.setFont(new Font(currentFont.getFontName(), currentFont.getStyle(), 24));
content.add(Title);
JTextArea ChatViewer = new JTextArea(18,30);
ChatViewer.setText("The chat messages are displayed here.");
JScrollPane scroll = new JScrollPane(ChatViewer);
JTextArea userChat = new JTextArea(5,30);
userChat.setText("This is for the user to insert text");
JScrollPane scroll2 = new JScrollPane(userChat);
JTextArea contacts = new JTextArea(18, 15);
contacts.setText("contact 1\ncontact 2\ncontact 3");
JScrollPane scroll3 = new JScrollPane(contacts);
JButton Send = new JButton("Send ");
Send.setBackground(Color.green);
SendButtonHandler sendhandler = new SendButtonHandler();
Send.addActionListener(sendhandler);
content.add(scroll);
content.add(scroll2);
content.add(scroll3);
content.add(Send);
Insets position = content.getInsets();
Dimension size;
size= Title.getPreferredSize();
Title.setBounds(20+position.left, 10+position.top, size.width, size.height);
size= scroll.getPreferredSize();
scroll.setBounds(20+position.left, 40+position.top, size.width, size.height);
size= scroll2.getPreferredSize();
scroll2.setBounds(20+position.left, 350+position.top, size.width, size.height);
size= scroll3.getPreferredSize();
scroll3.setBounds(370+position.left, 40+position.top, size.width, size.height);
size= Send.getPreferredSize();
Send.setBounds(370+position.left, 350+position.top, size.width, size.height);
}
private class SendButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
}
}
}