From d9738419c30f0d2b228f4f5e255a81901d4fa7ea Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Fri, 9 Feb 2024 21:46:26 +0100 Subject: [PATCH] Refactor: Create input text field from new 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 90966c8..afbb516 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -104,15 +104,12 @@ public class ChatClient extends JFrame implements KeyListener { private void initGui() { prepareOutputTextArea(); + createInputTextField(); timeLabel = new JLabel(); updateTime(); add(timeLabel, BorderLayout.NORTH); - inputTextField = new JTextField(); - inputTextField.setBorder(BorderFactory.createTitledBorder("Nachricht eingeben")); - inputTextField.addKeyListener(this); - add(outputScrollPane, BorderLayout.CENTER); add(inputTextField, BorderLayout.SOUTH); @@ -131,6 +128,12 @@ public class ChatClient extends JFrame implements KeyListener { outputScrollPane = new JScrollPane(outputTextArea); } + private void createInputTextField() { + inputTextField = new JTextField(); + inputTextField.setBorder(BorderFactory.createTitledBorder("Nachricht eingeben")); + inputTextField.addKeyListener(this); + } + private void receiveMessages() { try { connectionToServer = new Socket(address, Constants.PORT);