The Window
and its superclass
Panel
have a single root layout component. The
component is usually a Layout
, but any
ComponentContainer
is allowed. When you create the
components, they create a default root layout, usually
VerticalLayout
, but you can change it with the
setContent()
method.
Window main = new Window("My Application"); setMainWindow(main); // Set another root layout for the main window. TabSheet tabsheet = new TabSheet(); main.setContent(tabsheet);
The size of the root layout is the default size of the particular layout
component, for example, a VerticalLayout
has 100% width
and undefined height by default. In many applications, you want to use the
full area of the browser view. Setting the components contained inside the
root layout to full size is not enough, and would actually lead to an invalid
state if the height of the root layout is undefined.
// This is actually the default. main.setContent(new VerticalLayout()); // Set the size of the root layout to full width and height. main.getContent().setSizeFull(); // Add a title area on top of the screen. This takes just the // vertical space it needs. main.addComponent(new Label("My Application")); // Add a menu-view area that takes rest of the vertical space. HorizontalLayout menuview = new HorizontalLayout(); menuview.setSizeFull(); main.addComponent(menuview);
See Section 6.12.1, “Layout Size” for more information about setting layout sizes.