diff --git a/src/main/java/ChatGUI.java b/src/main/java/ChatGUI.java index 124332e..f6d09d7 100644 --- a/src/main/java/ChatGUI.java +++ b/src/main/java/ChatGUI.java @@ -50,6 +50,8 @@ public class ChatGUI implements ActionListener { inputTextField.setPreferredSize(new Dimension(0, 30)); gui.add(inputTextField, BorderLayout.SOUTH); + inputTextField.addActionListener(this); + // Set the size of the GUI to be a quarter of the screen size Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int quarterWidth = screenSize.width / 2; @@ -68,7 +70,12 @@ public class ChatGUI implements ActionListener { if (e.getSource() == exit) { System.exit(0); } + if (e.getSource() == inputTextField) { + String inputText = inputTextField.getText(); + outputTextArea.append(inputText + "\n"); + inputTextField.setText(""); } } +}