From a57bfabd7f5d437c65e3ea38e9aca4fda8812e68 Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 19:12:42 +0100 Subject: [PATCH] refactoring: Kommentare und Lesbarkeit --- src/main/java/ChatGUI.java | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index a521d26..93c62e7 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -33,7 +33,7 @@ public class ChatGUI implements ActionListener { JMenuItem green = new JMenuItem("green"); JMenuItem exit = new JMenuItem("Exit"); - + private JButton popupButton; JTextField inputTextField = new JTextField(); @@ -59,6 +59,7 @@ public class ChatGUI implements ActionListener { JMenu colors = new JMenu("font-colors"); JMenu size = new JMenu("font-size"); + // Create Pop-Up Button popupButton = new JButton("Popup-Nachricht senden"); popupButton.addActionListener(this); @@ -118,7 +119,7 @@ public class ChatGUI implements ActionListener { new ChatGUI(); } - + // add-message method with time stamp void addMessage(String message) { String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); @@ -157,17 +158,15 @@ public class ChatGUI implements ActionListener { outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 20)); } if (e.getSource() == popupButton) { - String message = inputTextField.getText(); - inputTextField.setText(""); - sendPopupMessage(message); - } + String message = inputTextField.getText(); + inputTextField.setText(""); + sendPopupMessage(message); + } - } - public void sendPopupMessage(String message) { - JOptionPane.showMessageDialog(gui, message); - } - + public void sendPopupMessage(String message) { + JOptionPane.showMessageDialog(gui, message); + } }