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

Menus

It's time for more concrete less abstract stuff. Let's talk about menus. Menus are a way to group functionality in a very small area of the page. The first step to create a menu, is to instantiate a new MenuBar:

MenuBar menuBar = new MenuBar();

Now, we can add a hierarchy of instances of MenuItem. To add items directly to the menu bar, you can do this:

MenuItem submenu1 = menuBar.addItem("Submenu 1", null);
MenuItem submenu2 = menuBar.addItem("Submenu 2", null);

This will show the following menu:

Menus

We can add child elements to the submenus:

submenu1.addItem("Option 1", null); submenu1.addItem("Option 2", null); submenu2.addItem("Option 3", null); ...

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