|
|
@ -87,10 +87,11 @@ public class ChatGUI implements ActionListener { |
|
|
|
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); |
|
|
|
inputPanel.add(sendButton, BorderLayout.EAST); |
|
|
|
gui.add(inputPanel, BorderLayout.SOUTH); |
|
|
|
inputPanel.add(inputTextField, BorderLayout.CENTER); |
|
|
|
inputPanel.add(sendButton, BorderLayout.EAST); |
|
|
|
gui.add(inputPanel, BorderLayout.SOUTH); |
|
|
|
|
|
|
|
inputTextField.addActionListener(this); |
|
|
|
sendButton.addActionListener(this); |
|
|
@ -102,6 +103,7 @@ public class ChatGUI implements ActionListener { |
|
|
|
gui.setSize(quarterWidth, quarterHeight); |
|
|
|
gui.setVisible(true); |
|
|
|
} |
|
|
|
|
|
|
|
// main methode zum Testen, müsste bei Implementation entfernt werden |
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
|
@ -114,9 +116,9 @@ public class ChatGUI implements ActionListener { |
|
|
|
System.exit(0); |
|
|
|
} |
|
|
|
if (e.getSource() == inputTextField || e.getSource() == sendButton) { |
|
|
|
String inputText = inputTextField.getText(); |
|
|
|
outputTextArea.append(inputText + "\n"); |
|
|
|
inputTextField.setText(""); |
|
|
|
String inputText = inputTextField.getText(); |
|
|
|
outputTextArea.append(inputText + "\n"); |
|
|
|
inputTextField.setText(""); |
|
|
|
} |
|
|
|
if (e.getSource() == red) { |
|
|
|
outputTextArea.setForeground(Color.RED); |
|
|
@ -128,17 +130,15 @@ public class ChatGUI implements ActionListener { |
|
|
|
} else if (e.getSource() == green) { |
|
|
|
outputTextArea.setForeground(Color.GREEN); |
|
|
|
} |
|
|
|
if(e.getSource() == small) { |
|
|
|
outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 12)); |
|
|
|
} |
|
|
|
if(e.getSource() == medium) { |
|
|
|
outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 16)); |
|
|
|
} |
|
|
|
if(e.getSource() == large) { |
|
|
|
outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 20)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (e.getSource() == small) { |
|
|
|
outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 12)); |
|
|
|
} |
|
|
|
if (e.getSource() == medium) { |
|
|
|
outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 16)); |
|
|
|
} |
|
|
|
if (e.getSource() == large) { |
|
|
|
outputTextArea.setFont(outputTextArea.getFont().deriveFont(Font.PLAIN, 20)); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |