-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatboxui.java
154 lines (135 loc) · 4.15 KB
/
chatboxui.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class chatboxui extends JPanel
{
Point bf;
public chatboxui(Point bornfrom)
{
super();
bf=bornfrom;
this.setLayout(new GridLayout(2,0));
this.setLocation(0,440);
this.setSize(565-80,640-440);
this.setBorder(BorderFactory.createTitledBorder(("Chat with "+game.getOppositePlayer().getName()+" ")));
//this.setVisible(false);
//jInternalFrame.setVisible(true);
//jInternalFrame.setClosable(true);
//this.setResizable(false);
//jf.add(jInternalFrame);
//jf.repaint();
ATextArea tx=new ATextArea();
tx.setBounds(0,0,2,2);
//tx.setLineWrap(true);
tx.setEditable(false);
//tx.setWrapStyleWord(true);
tf=new ATextField();
tf.setBounds(0,250,getWidth(),getHeight()-tx.getHeight());
Font font=new Font("Segoe UI Emoji",Font.PLAIN,22);
tx.setFont(font);
tf.setFont(font);
JPanel input=new JPanel();
input.setLayout(new GridLayout(2,0));
JScrollPane fd=new JScrollPane(tx,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
fd.setBounds(0,0,500,250);
//fs.add(fd);
this.add(fd);
input.add(tf);
input.add(new JLabel("Options for chatting like buttons for instant emoji (reactions)"));
this.add(input);
tf.addKeyListener(new KeyAdapter()
{
public void keyReleased(KeyEvent ke)
{
if(ke.getKeyCode()==KeyEvent.VK_ENTER)
{
String s=tf.getText();
tf.setText("");
tx.append("["+"You"+"] "+s+"\n");
//networkhr.chatout.println(s);
/**
* write the message to chatsocket
*/
}
}
});
//new Thread(new networkhr.chatinreader(tx)).start();
}
public JTextField tf;
@Override
public void setVisible(boolean b)
{
new Thread(new Runnable()
{
public void run()
{
move(b);
}
}).start();
}
public void fastSetVisible(boolean b)
{
super.setVisible(b);
}
public void move(boolean b)
{
if(b)
{
double k=0;
super.setVisible(b);
while(k<=1)
{
this.setLocation((int)(600*(1-k)),440);
k+=0.02;
gui.frame.revalidate();
try
{
Thread.sleep(2);
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}
}
this.setLocation(0,440);
}
else
{
double k=1;
while(k>=0)
{
this.setLocation((int)(600*(1-k)),440);
k-=0.02;
gui.frame.revalidate();
try
{
Thread.sleep(2);
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}
}
this.setLocation(600,440);
super.setVisible(b);
}
}
static class ATextArea extends JTextArea
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(new Color(colortrans.r,colortrans.b,colortrans.g,80));
g.fillRect(0,0,getWidth(),getHeight());
}
}
static class ATextField extends JTextField
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
g.setColor(new Color(colortrans.g,colortrans.b,colortrans.r,80));
g.fillRect(0,0,getWidth(),getHeight());
}
}
}