diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index ac9268b..b8fd458 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -1,6 +1,8 @@ import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.io.*; @@ -70,6 +72,7 @@ public class ChatClient extends JFrame implements KeyListener { private JTextArea outputTextArea; private JTextField inputTextField; private JScrollPane outputScrollPane; + private Timer timer; public ChatClient() { super("Chat"); @@ -80,6 +83,16 @@ public class ChatClient extends JFrame implements KeyListener { } } + private void initTimer() { + timer = new Timer(1000, new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + //Method to update time + } + }); + timer.start(); + } + private void initGui() { outputTextArea = new JTextArea(); outputTextArea.setEditable(false); @@ -107,6 +120,7 @@ public class ChatClient extends JFrame implements KeyListener { toServerWriter = new PrintWriter(new OutputStreamWriter(connectionToServer.getOutputStream())); initGui(); + initTimer(); while (true) { String message = fromServerReader.readLine();