/**
* Initialize Application. Demo components are added to main window.
*/
@Override
public void init() {
final LegacyWindow mainWindow = new LegacyWindow("Layout demo");
setMainWindow(mainWindow);
// Create horizontal ordered layout
VerticalLayout panelALayout = new VerticalLayout();
panelALayout.setMargin(true);
final Panel panelA = new Panel(
"Panel containing horizontal ordered layout", panelALayout);
HorizontalLayout layoutA = new HorizontalLayout();
// Add 4 random components
fillLayout(layoutA, componentCountA);
// Add layout to panel
panelALayout.addComponent(layoutA);
// Create vertical ordered layout
VerticalLayout panelBLayout = new VerticalLayout();
panelBLayout.setMargin(true);
final Panel panelB = new Panel(
"Panel containing vertical ordered layout", panelBLayout);
VerticalLayout layoutB = new VerticalLayout();
// Add 4 random components
fillLayout(layoutB, componentCountB);
// Add layout to panel
panelBLayout.addComponent(layoutB);
// Create grid layout
final int gridSize = (int) java.lang.Math.sqrt(componentCountC);
VerticalLayout panelGLayout = new VerticalLayout();
panelGLayout.setMargin(true);
final Panel panelG = new Panel("Panel containing grid layout ("
+ gridSize + " x " + gridSize + ")", panelGLayout);
GridLayout layoutG = new GridLayout(gridSize, gridSize);
// Add 12 random components
fillLayout(layoutG, componentCountC);
// Add layout to panel
panelGLayout.addComponent(layoutG);
// Create TabSheet
final TabSheet tabsheet = new TabSheet();
tabsheet.setCaption("Tabsheet, above layouts are added to this component");
layoutA = new HorizontalLayout();
// Add 4 random components
fillLayout(layoutA, componentCountA);
tabsheet.addTab(layoutA, "Horizontal ordered layout", null);
layoutB = new VerticalLayout();
// Add 4 random components
fillLayout(layoutB, componentCountB);
tabsheet.addTab(layoutB, "Vertical ordered layout", null);
layoutG = new GridLayout(gridSize, gridSize);
// Add 12 random components
fillLayout(layoutG, componentCountC);
tabsheet.addTab(layoutG, "Grid layout (4 x 2)", null);
// Create custom layout
VerticalLayout panelCLayout = new VerticalLayout();
panelCLayout.setMargin(true);
final Panel panelC = new Panel("Custom layout with style exampleStyle",
panelCLayout);
final CustomLayout layoutC = new CustomLayout("exampleStyle");
// Add 4 random components
fillLayout(layoutC, componentCountD);
// Add layout to panel
panelCLayout.addComponent(layoutC);
// Add demo panels (layouts) to main window
mainWindow.addComponent(panelA);
mainWindow.addComponent(panelB);
mainWindow.addComponent(panelG);
mainWindow.addComponent(tabsheet);
mainWindow.addComponent(panelC);
}