-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextAction.java
More file actions
34 lines (28 loc) · 1.03 KB
/
TextAction.java
File metadata and controls
34 lines (28 loc) · 1.03 KB
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
import java.awt.event.ActionEvent;
import java.net.ConnectException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
public class TextAction extends AbstractAction {
public static boolean online = false;
public void actionPerformed(ActionEvent evt) {
if (online) {
Date d = new Date();
SimpleDateFormat format1 = new SimpleDateFormat("dd.MM.yyyy kk:mm:ss");
String text = Interface.textField.getText();
Interface.cli.getMessage(text);
text = text + "\r\n";
StringBuilder sb = new StringBuilder();
sb.append("[");
sb.append(format1.format(d));
sb.append(" | You]: ");
sb.append(text);
Interface.textArea.append("You: " + text);
TextFile.update(sb.toString());
Interface.textField.setText("");
} else {
//Interface.textArea.append("No connection" + "\n");
Interface.status.setText("No connection");
}
}
}