Like in topic. It seems that setMinSize(), setMaxSize() and any other attemts to modify BoxLayout and its components sizes are ignored. Can someone explain me why this happens? Example code:
Interface superclass:
package gui;
import de.matthiasmann.twl.DesktopArea;
import de.matthiasmann.twl.GUI;
import de.matthiasmann.twl.Widget;
public abstract class Interface {
private final DesktopArea widget;
Interface() {
widget = new DesktopArea();
GUI gui = new GUI(widget, InterfaceManager.getRenderer());
gui.applyTheme(InterfaceManager.getTheme());
gui.validateLayout();
}
protected void add(Widget w) {
widget.add(w);
}
GUI getGUI() {
return widget.getGUI();
}
protected DesktopArea getInterface() {
return widget;
}
}
Main menu:
package gui;
import de.matthiasmann.twl.*;
public class MainMenu extends Interface {
MainMenu() {
BoxLayout layout = new BoxLayout();
layout.setMinSize(400, 100);
layout.setMaxSize(400, 100);
layout.setSize(400, 100);
final Button button = new Button("9998");
button.setMinSize(100, 30);
button.setMaxSize(100, 30);
button.setSize(100, 30);
button.addCallback(new Runnable() {
public void run() {
action(button);
}
});
final Button button2 = new Button("-5");
button2.addCallback(new Runnable() {
public void run() {
action(button2);
}
});
final EditField field = new EditField();
layout.setDirection(BoxLayout.Direction.VERTICAL);
layout.setPosition(100, 100);
layout.add(button);
layout.add(button2);
layout.add(field);
add(layout);
}
private void action(Button button) {
button.setText(String.valueOf(Integer.parseInt(button.getText())+1));
}
}