I’d like to have a explicitly sized window that contains one variable-width layout that has a scrollbar if neccessary, but other components in the window are sized to the window. I’ll demonstrate with a test case.
public class TestCase extends Application {
private final Window main = new Window();
@Override
public void init() {
setMainWindow(main);
Window window = new Window();
window.setWidth("400px");
HorizontalLayout layoutWithScrollbar = new HorizontalLayout();
for (int i = 0; i < 10; i++)
layoutWithScrollbar.addComponent(new Label("foobarbaz label " + i));
window.addComponent(layoutWithScrollbar);
Label labelThatWraps = new Label(
"wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap wrap");
window.addComponent(labelThatWraps);
main.addWindow(window);
}
This works almost like I want except I get no scrollbar on the HorizontalLayout. I can get a scrollbar on the whole window root layout by adding
window.getLayout().setSizeUndefined();
but that will contain the lower label too, which is not what I want. If I replace the layout with a Panel I get a scrollbar on it just like I want, but a Panel has a slew of other features (visual and otherwise) I don’t need.