Panels resize properly now

This commit is contained in:
Thastertyn 2023-05-03 22:25:58 +02:00
parent 25609a8822
commit 88aec67833

View File

@ -37,7 +37,8 @@ public class WindowSwitchListener implements WindowListener, UpdateListener {
private Label[] tabs = new Label[contents.length]; 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(); private Panel holderPanel = new Panel();
int current = contents.length - 1; int current = contents.length - 1;
@ -118,7 +119,9 @@ public class WindowSwitchListener implements WindowListener, UpdateListener {
if(currentColumns < tabColumns) if(currentColumns < tabColumns)
{ {
holderPanel.addComponent( holderPanel.addComponent(
contents[current].getPanel().setPreferredSize(new TerminalSize( contents[current].getPanel()
.setPreferredSize(
new TerminalSize(
tabColumns - 2, tabColumns - 2,
contents[current].getPanel().getPreferredSize().getRows()))); contents[current].getPanel().getPreferredSize().getRows())));
return; return;
@ -195,7 +198,8 @@ public class WindowSwitchListener implements WindowListener, UpdateListener {
@Override @Override
public void updatePanel() { public void updatePanel() {
holderPanel.removeAllComponents(); 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()); holderPanel.addComponent(contents[current].getPanel());
} }