6.2. Window and Panel Root Layout

 
6.2. Window and Panel Root Layout
Prev Chapter 6. Managing Layout Next

6.2. Window and Panel Root Layout

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.


Prev Up Next
Chapter 6. Managing Layout Home 6.3. VerticalLayout and HorizontalLayout
Version: 6.7.0© Oy IT Mill Ltd. 2000-2011