|
|
@ -88,7 +88,7 @@ public class ChatGUI implements ActionListener { |
|
|
|
// Set up the output text area with scrolling |
|
|
|
JScrollPane outputScrollPane = new JScrollPane(outputTextArea); |
|
|
|
gui.add(outputScrollPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
// Set up the input panel with text field and send button |
|
|
|
JPanel inputPanel = new JPanel(new BorderLayout()); |
|
|
|
inputPanel.add(inputTextField, BorderLayout.CENTER); |
|
|
@ -141,12 +141,14 @@ public class ChatGUI implements ActionListener { |
|
|
|
if (e.getSource() == large) { |
|
|
|
outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 20)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// add-message method with time stamp |
|
|
|
private void addMessage(String message) { |
|
|
|
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
|
outputTextArea.append("[" + timeStamp + "] " + message + "\n"); |
|
|
|
outputTextArea.setCaretPosition(outputTextArea.getDocument().getLength()); |
|
|
|
String timeStamp = new SimpleDateFormat("HH:mm:ss").format(new Date()); |
|
|
|
outputTextArea.append("[" + timeStamp + "] " + message + "\n"); |
|
|
|
outputTextArea.setCaretPosition(outputTextArea.getDocument().getLength()); |
|
|
|
|
|
|
|
} |
|
|
|
} |