From 88aec6783387fb5efb63c0a1157da1a34e9d9f3d Mon Sep 17 00:00:00 2001 From: Thastertyn Date: Wed, 3 May 2023 22:25:58 +0200 Subject: [PATCH] Panels resize properly now --- .../UserInterface/WindowSwitchListener.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/xyz/thastertyn/UserInterface/WindowSwitchListener.java b/src/main/java/xyz/thastertyn/UserInterface/WindowSwitchListener.java index 1011535..f969a5f 100644 --- a/src/main/java/xyz/thastertyn/UserInterface/WindowSwitchListener.java +++ b/src/main/java/xyz/thastertyn/UserInterface/WindowSwitchListener.java @@ -37,7 +37,8 @@ public class WindowSwitchListener implements WindowListener, UpdateListener { private Label[] tabs = new Label[contents.length]; - private Panel tabsPanel = new Panel().setLayoutManager(new LinearLayout(Direction.HORIZONTAL)); + private Panel tabsPanel = new Panel() + .setLayoutManager(new LinearLayout(Direction.HORIZONTAL)); private Panel holderPanel = new Panel(); int current = contents.length - 1; @@ -114,13 +115,15 @@ public class WindowSwitchListener implements WindowListener, UpdateListener { .getPanel() .getSize() .getColumns(); - + if(currentColumns < tabColumns) { holderPanel.addComponent( - contents[current].getPanel().setPreferredSize(new TerminalSize( - tabColumns - 2, - contents[current].getPanel().getPreferredSize().getRows()))); + contents[current].getPanel() + .setPreferredSize( + new TerminalSize( + tabColumns - 2, + contents[current].getPanel().getPreferredSize().getRows()))); return; } @@ -195,7 +198,8 @@ public class WindowSwitchListener implements WindowListener, UpdateListener { @Override public void updatePanel() { holderPanel.removeAllComponents(); - // Todo find a way to resize the panel on screen + contents[current].getPanel().setPreferredSize(contents[current].getPanel().calculatePreferredSize()); + setPanelPreferedSize(); holderPanel.addComponent(contents[current].getPanel()); }