From a0d94ed9f8e4eae8d7a13c394d1ae36b5ec875d0 Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Wed, 7 Feb 2024 19:13:56 +0100 Subject: [PATCH] Add scrollbar to window --- src/main/java/ChatClient.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index 0179d4c..44a0bc6 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -15,6 +15,7 @@ public class ChatClient extends JFrame implements KeyListener { // GUI private JTextArea outputTextArea; private JTextField inputTextField; + private JScrollPane outputScrollPane; public ChatClient(int port) { super("Chat"); @@ -31,11 +32,13 @@ public class ChatClient extends JFrame implements KeyListener { outputTextArea.setEditable(false); outputTextArea.setBorder(BorderFactory.createTitledBorder("Chat")); + outputScrollPane = new JScrollPane(outputTextArea); + inputTextField = new JTextField(); inputTextField.setBorder(BorderFactory.createTitledBorder("Nachricht eingeben")); inputTextField.addKeyListener(this); - add(outputTextArea, BorderLayout.CENTER); + add(outputScrollPane, BorderLayout.CENTER); add(inputTextField, BorderLayout.SOUTH); setVisible(true);