Time for action – adding menu options

Follow these steps to add the buttons that will form the main menu of the application:

  1. Add the following method to MainLayout:
    public class MainLayout extends VerticalLayout {
    
      ...
    
      public void addMenuOption(String caption,
          final Component component) {
        Button button = new Button(caption);
        menuLayout.addComponent(button);
    
        button.addClickListener(new ClickListener() {
          public void buttonClick(ClickEvent event) {
            contentLayout.removeAllComponents();
            contentLayout.addComponent(component);
          }
        });
      }
    }
  2. Comment out the line that set menuLayout to be full size:
    public MainLayout() {
    
      ...
    
      //menuLayout.setSizeFull(); you can delete this line ;)
    
      ...
    
    }
  3. Change your LayoutFrameworkUI class to the following:
    public class ...

Get Vaadin 7 UI Design By Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.