From ac8678e7cf3394de8330fc01ca01def2fa625fa3 Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Fri, 9 Feb 2024 12:26:10 +0100 Subject: [PATCH] Refactor: move panel --- src/main/java/ChatClient.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index 2328cb2..ac9268b 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -1,4 +1,5 @@ import javax.swing.*; +import javax.swing.border.EmptyBorder; import java.awt.*; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; @@ -8,7 +9,10 @@ import java.net.Socket; public class ChatClient extends JFrame implements KeyListener { public static class TR extends JFrame { + + private JScrollPane jScrollPane; + private JPanel container; public TR() throws HeadlessException { super("Notizen"); @@ -19,7 +23,7 @@ public class ChatClient extends JFrame implements KeyListener { private void initComponents() { setVisible(true); - setBounds(200, 200, 350, 550); + setBounds(1180, 170, 350, 550); setPreferredSize(new Dimension(300, 500)); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setResizable(false); @@ -29,9 +33,14 @@ public class ChatClient extends JFrame implements KeyListener { setContentPane(root); - jScrollPane = new JScrollPane( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + jScrollPane = new JScrollPane(container, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); jScrollPane.setPreferredSize(new Dimension(300, 500)); root.add(jScrollPane); + + container = new JPanel(); + container.setBorder(new EmptyBorder(3, 3, 3, 3)); + container.setBackground(new Color(0x839683)); + container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); } private JPanel setupPanel(String header) { @@ -39,6 +48,8 @@ public class ChatClient extends JFrame implements KeyListener { panel.setPreferredSize(new Dimension(270, 150)); panel.setLayout(new BorderLayout()); + container.add(panel); + container.add(Box.createVerticalStrut(5)); JLabel jLabel = new JLabel(header); jLabel.setHorizontalAlignment(JLabel.LEFT);