O'Reilly logo

Vaadin 7 UI Design By Example Beginner's Guide by Alejandro Duarte

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required