Browse Source

Add method to initialize timer

remotes/origin/hotfix/client/improve-chat-window-appearence
Alena Bandarovich 11 months ago
parent
commit
2579040ed7
  1. 14
      src/main/java/ChatClient.java

14
src/main/java/ChatClient.java

@ -1,6 +1,8 @@
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.io.*; import java.io.*;
@ -70,6 +72,7 @@ public class ChatClient extends JFrame implements KeyListener {
private JTextArea outputTextArea; private JTextArea outputTextArea;
private JTextField inputTextField; private JTextField inputTextField;
private JScrollPane outputScrollPane; private JScrollPane outputScrollPane;
private Timer timer;
public ChatClient() { public ChatClient() {
super("Chat"); 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() { private void initGui() {
outputTextArea = new JTextArea(); outputTextArea = new JTextArea();
outputTextArea.setEditable(false); outputTextArea.setEditable(false);
@ -107,6 +120,7 @@ public class ChatClient extends JFrame implements KeyListener {
toServerWriter = new PrintWriter(new OutputStreamWriter(connectionToServer.getOutputStream())); toServerWriter = new PrintWriter(new OutputStreamWriter(connectionToServer.getOutputStream()));
initGui(); initGui();
initTimer();
while (true) { while (true) {
String message = fromServerReader.readLine(); String message = fromServerReader.readLine();

Loading…
Cancel
Save