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 = 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:
We can add child elements to the submenus:
submenu1.addItem("Option 1", null); submenu1.addItem("Option 2", null); submenu2.addItem("Option 3", null); ...