static JTextField textField = null;
static JTextArea messageArea = null;
static String serverAddress = "localhost";
static UFTtrack window = null;
public static JFrame frame;
public ImageIcon[] images;
static JTable table;
Date lastUpdate;
static Timer timer;
static Scanner in;
static PrintWriter out;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@SuppressWarnings({ "static-access" })
public void run() {
try {
UIManager.setLookAndFeel(new MaterialLookAndFeel());
} catch (UnsupportedLookAndFeelException e1) {
e1.printStackTrace();
}
try {
window = new UFTtrack();
placeChatOnScreen();
createTable();
SystemTrayz.createTray();
centreWindow(frame);
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public UFTtrack() {
initialize();
}
private void initialize() {
frame = new JFrame("UFTtrack");
frame.setTitle("UFT Tracker");
frame.setResizable(false);
frame.setLocationByPlatform(true);
frame.setSize(1308, 900);
frame.setBounds(100, 100, 450, 300);
frame.setMinimumSize(new Dimension(1308, 900));
frame.setPreferredSize(new Dimension(1308, 900));
frame.setLayout(null);
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}
@SuppressWarnings({ "resource", "unused" })
private static void placeChatOnScreen() {
try {
textField = new JTextField();
textField.setFont(new Font("Segoe UI", Font.PLAIN, 13));
textField.setDragEnabled(true);
textField.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
textField.setBounds(338, 838, 954, 22);
frame.getContentPane().add(textField);
messageArea = new JTextArea();
messageArea.setEditable(false);
messageArea.setFont(new Font("Segoe UI", Font.PLAIN, 13));
messageArea.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
messageArea.setDragEnabled(true);
messageArea.setName("chatArea");
messageArea.setWrapStyleWord(true);
messageArea.setBounds(338, 648, 954, 181);
frame.getContentPane().add(messageArea);
textField.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
out.println(textField.getText());
textField.setText("");
}
});
Socket socket = new Socket("localhost", 8877);
in = new Scanner(socket.getInputStream());
out = new PrintWriter(socket.getOutputStream(), true);
while (in.hasNextLine()) {
String line = in.nextLine();
if (line.startsWith("SUBMITNAME")) {
out.println(getName());
} else if (line.startsWith("NAMEACCEPTED")) {
textField.setEditable(true);
} else if (line.startsWith("MESSAGE")) {
messageArea.append(line.substring(8) + "\n");
}
}
} catch (IOException e1) {
e1.printStackTrace();
}
}