From 13f12889773daf87d29d2304b966147d6c9352ca Mon Sep 17 00:00:00 2001 From: Paul Kattenborn Date: Fri, 9 Feb 2024 19:10:46 +0100 Subject: [PATCH] =?UTF-8?q?Popup-Button=20Funktionalit=C3=A4t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/ChatGUI.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 2f8e4ad..a521d26 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -60,6 +60,7 @@ public class ChatGUI implements ActionListener { JMenu size = new JMenu("font-size"); popupButton = new JButton("Popup-Nachricht senden"); + popupButton.addActionListener(this); JMenu menu = new JMenu("File"); menu.add(exit); @@ -155,10 +156,14 @@ public class ChatGUI implements ActionListener { if (e.getSource() == large) { outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 20)); } + if (e.getSource() == popupButton) { + String message = inputTextField.getText(); + inputTextField.setText(""); + sendPopupMessage(message); + } } - public class NotificationManager { public void sendPopupMessage(String message) { JOptionPane.showMessageDialog(gui, message); @@ -166,4 +171,3 @@ public class ChatGUI implements ActionListener { } -}