Time for action – using grid layouts
Follow these steps to add a funny grid layout:
First, stop showing the blue borders for layouts by commenting out or deleting the following line (find it in
MainLayout
's constructor)://showBorders();
Now, in the
LayoutFrameworkUI
class, add agetGridLayout
method and call it frominit
to add the returned component to ourlayout
:public class LayoutFrameworkUI extends UI { protected void init(VaadinRequest request) { ... layout.addMenuOption("Grid layout", getGridLayout()); } private GridLayout getGridLayout() { int rows = 3, columns = 3; GridLayout gridLayout = new GridLayout(columns, rows); gridLayout.setSizeFull(); for (int row = 0; row < rows; row++) { for (int column = 0; column < columns; column++) { Button button = new Button("-_-"); gridLayout.addComponent(button, column, row); } } return gridLayout; } }
Run the application and click the Grid layout button to see the...