Browse Source

Add scrollbar to window

remotes/origin/feature/client/exchange-messages-between-client-server
Alena Bandarovich 11 months ago
parent
commit
a0d94ed9f8
  1. 5
      src/main/java/ChatClient.java

5
src/main/java/ChatClient.java

@ -15,6 +15,7 @@ public class ChatClient extends JFrame implements KeyListener {
// GUI // GUI
private JTextArea outputTextArea; private JTextArea outputTextArea;
private JTextField inputTextField; private JTextField inputTextField;
private JScrollPane outputScrollPane;
public ChatClient(int port) { public ChatClient(int port) {
super("Chat"); super("Chat");
@ -31,11 +32,13 @@ public class ChatClient extends JFrame implements KeyListener {
outputTextArea.setEditable(false); outputTextArea.setEditable(false);
outputTextArea.setBorder(BorderFactory.createTitledBorder("Chat")); outputTextArea.setBorder(BorderFactory.createTitledBorder("Chat"));
outputScrollPane = new JScrollPane(outputTextArea);
inputTextField = new JTextField(); inputTextField = new JTextField();
inputTextField.setBorder(BorderFactory.createTitledBorder("Nachricht eingeben")); inputTextField.setBorder(BorderFactory.createTitledBorder("Nachricht eingeben"));
inputTextField.addKeyListener(this); inputTextField.addKeyListener(this);
add(outputTextArea, BorderLayout.CENTER);
add(outputScrollPane, BorderLayout.CENTER);
add(inputTextField, BorderLayout.SOUTH); add(inputTextField, BorderLayout.SOUTH);
setVisible(true); setVisible(true);

Loading…
Cancel
Save