/* @ITMillApache2LicenseForJavaFiles@ */ package com.itmill.toolkit.tests; import com.itmill.toolkit.terminal.ClassResource; import com.itmill.toolkit.ui.Component; import com.itmill.toolkit.ui.Embedded; import com.itmill.toolkit.ui.GridLayout; import com.itmill.toolkit.ui.Label; import com.itmill.toolkit.ui.Layout; import com.itmill.toolkit.ui.OrderedLayout; import com.itmill.toolkit.ui.Panel; import com.itmill.toolkit.ui.TabSheet; import com.itmill.toolkit.ui.Window; /** * This example demonstrates layouts. Layouts are populated with sample Toolkit * UI components. * * @author IT Mill Ltd. * @since 4.0.0 * */ public class LayoutDemo extends com.itmill.toolkit.Application { /** * Initialize Application. Demo components are added to main window. */ @Override public void init() { final Window mainWindow = new Window("Layout demo"); setMainWindow(mainWindow); // // Create horizontal ordered layout // final OrderedLayout layoutA = new OrderedLayout( OrderedLayout.ORIENTATION_HORIZONTAL); // Add 4 panels fillLayout(layoutA, 4); // // Create vertical ordered layout // final OrderedLayout layoutB = new OrderedLayout( OrderedLayout.ORIENTATION_VERTICAL); // Add 4 panels fillLayout(layoutB, 4); // // Create grid layout // final GridLayout layoutG = new GridLayout(4, 4); // Add 16 panels components fillLayout(layoutG, 16); // // Create grid layout // final GridLayout layoutG2 = new GridLayout(4, 4); // Add 4 panels with absolute coordinates (diagonally) layoutG2.addComponent(getExampleComponent("x=0, y=0"), 0, 0); layoutG2.addComponent(getExampleComponent("x=1, y=1"), 1, 1); layoutG2.addComponent(getExampleComponent("x=2, y=2"), 2, 2); layoutG2.addComponent(getExampleComponent("x=3, y=3"), 3, 3); // Add 4 pictures with absolute coordinates (diagonally) layoutG2.addComponent(getExamplePicture("x=3, y=0"), 3, 0); layoutG2.addComponent(getExamplePicture("x=2, y=1"), 2, 1); layoutG2.addComponent(getExamplePicture("x=1, y=2"), 1, 2); layoutG2.addComponent(getExamplePicture("x=0, y=3"), 0, 3); // // Create TabSheet // final TabSheet tabsheet = new TabSheet(); tabsheet .setCaption("Tabsheet, above layouts are added to this component"); tabsheet.addTab(layoutA, "Horizontal ordered layout", null); tabsheet.addTab(layoutB, "Vertical ordered layout", null); tabsheet.addTab(layoutG, "First grid layout", null); tabsheet.addTab(layoutG2, "Second grid layout", null); // // Add demo layouts to main window // mainWindow.addComponent(new Label( "