From 2810433d0c0db1a41084735ac22238ef58c977e8 Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Fri, 9 Feb 2024 22:03:55 +0100 Subject: [PATCH] Refactor: Use showCurrentTime method --- src/main/java/ChatClient.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index afbb516..7621057 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -105,13 +105,11 @@ public class ChatClient extends JFrame implements KeyListener { private void initGui() { prepareOutputTextArea(); createInputTextField(); - - timeLabel = new JLabel(); - updateTime(); - add(timeLabel, BorderLayout.NORTH); + showCurrentTime(); add(outputScrollPane, BorderLayout.CENTER); add(inputTextField, BorderLayout.SOUTH); + add(timeLabel, BorderLayout.NORTH); setVisible(true); setSize(Constants.WINDOW_WIDTH, Constants.WINDOW_HEIGHT); @@ -134,6 +132,11 @@ public class ChatClient extends JFrame implements KeyListener { inputTextField.addKeyListener(this); } + private void showCurrentTime(){ + timeLabel = new JLabel(); + updateTime(); + } + private void receiveMessages() { try { connectionToServer = new Socket(address, Constants.PORT);