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