Browse Source

Merge branch 'server' into 'main'

Server

See merge request fdai7332/java-chat!13
remotes/origin/hotfix/client/improve-chat-window-appearence
fdai7599 11 months ago
parent
commit
695d9b2b47
  1. 19
      src/main/java/ChatGUI.java
  2. 10
      src/test/java/ChatGUITest.java

19
src/main/java/ChatGUI.java

@ -34,7 +34,7 @@ public class ChatGUI implements ActionListener {
JMenuItem exit = new JMenuItem("Exit");
private JButton popupButton;
JButton popupButton;
JTextField inputTextField = new JTextField();
JTextArea outputTextArea = new JTextArea();
@ -59,7 +59,9 @@ 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);
JMenu menu = new JMenu("File");
menu.add(exit);
@ -155,15 +157,16 @@ 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);
}
public void sendPopupMessage(String message) {
JOptionPane.showMessageDialog(gui, message);
}
}
}

10
src/test/java/ChatGUITest.java

@ -92,6 +92,16 @@ public class ChatGUITest {
assertTrue(chatGUI.outputTextArea.getText().contains(expectedMessage));
}
@Test
public void testSendPopupMessage() {
ChatGUI chatGUI = new ChatGUI();
String testMessage = "Test Popup-Nachricht";
chatGUI.sendPopupMessage(testMessage);
}
}
Loading…
Cancel
Save