From 771f121d19e465646a29198d3525cc884994f6dc Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 17:09:55 +0100 Subject: [PATCH] refactoring: Code lesbarer --- src/main/java/ChatGUI.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 765d6d7..2011bc9 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -88,7 +88,7 @@ public class ChatGUI implements ActionListener { // Set up the output text area with scrolling JScrollPane outputScrollPane = new JScrollPane(outputTextArea); gui.add(outputScrollPane, BorderLayout.CENTER); - + // Set up the input panel with text field and send button JPanel inputPanel = new JPanel(new BorderLayout()); inputPanel.add(inputTextField, BorderLayout.CENTER); @@ -141,12 +141,14 @@ public class ChatGUI implements ActionListener { if (e.getSource() == large) { outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 20)); } - - } + + } + + // add-message method with time stamp private void addMessage(String message) { - String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); - outputTextArea.append("[" + timeStamp + "] " + message + "\n"); - outputTextArea.setCaretPosition(outputTextArea.getDocument().getLength()); + String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); + outputTextArea.append("[" + timeStamp + "] " + message + "\n"); + outputTextArea.setCaretPosition(outputTextArea.getDocument().getLength()); } }