public class MenuBarExample implements EntryPoint { public void onModuleLoad() { // Make a command that we will execute from all leaves. Command cmd = new Command() { public void execute() { Window.alert("You selected a menu item!"); } }; // Make some sub-menus that we will cascade from the top menu. MenuBar fooMenu = new MenuBar(true); fooMenu.addItem("the", cmd); fooMenu.addItem("foo", cmd); fooMenu.addItem("menu", cmd); MenuBar barMenu = new MenuBar(true); barMenu.addItem("the", cmd); barMenu.addItem("bar", cmd); barMenu.addItem("menu", cmd); MenuBar bazMenu = new MenuBar(true); bazMenu.addItem("the", cmd); bazMenu.addItem("baz", cmd); bazMenu.addItem("menu", cmd); // Make a new menu bar, adding a few cascading menus to it. MenuBar menu = new MenuBar(); menu.addItem("foo", fooMenu); menu.addItem("bar", barMenu); menu.addItem("baz", bazMenu); // Add it to the root panel. RootPanel.get().add(menu); } }
MenuBar() | Creates an empty horizontal menu bar. |
MenuBar(boolean) | Creates an empty menu bar. |
addItem(MenuItem) | Adds a menu item to the bar. |
addItem(String, boolean, Command) | Adds a menu item to the bar, that will fire the given command when it is selected. |
addItem(String, boolean, MenuBar) | Adds a menu item to the bar, that will open the specified menu when it is selected. |
addItem(String, Command) | Adds a menu item to the bar, that will fire the given command when it is selected. |
addItem(String, MenuBar) | Adds a menu item to the bar, that will open the specified menu when it is selected. |
clearItems() | Removes all menu items from this menu bar. |
getAutoOpen() | Gets whether this menu bar's child menus will open when the mouse is moved over it. |
getItems() | Returns a list containing the MenuItem objects in the menu bar. |
getSelectedItem() | Returns the MenuItem that is currently selected (highlighted)
by the user. |
onBrowserEvent(Event) | |
onDetach() | This method is called when a widget is detached from the browser's document. |
onPopupClosed(PopupPanel, boolean) | Fired when the popup is closed. |
removeItem(MenuItem) | Removes the specified menu item from the bar. |
setAutoOpen(boolean) | Sets whether this menu bar's child menus will open when the mouse is moved over it. |
true
to orient the menu bar verticallytrue
to treat the specified text as htmltrue
to treat the specified text as htmltrue
if child menus will auto-openMenuItem
objects in the menu bar.
If there are no items in the menu bar, then an empty List
object will be returned.MenuItem
objects in the menu
barMenuItem
that is currently selected (highlighted)
by the user. If none of the items in the menu are currently selected, then
null
will be returned.MenuItem
that is currently selected, or
null
if no items are currently selected
Subclasses that override this method must call
super.onDetach()
to ensure that the Widget has been detached
from the underlying Element. Failure to do so will result in application
memory leaks due to circular references between DOM Elements and JavaScript
objects.
true
if the popup was automatically
closed; false
if it was closed programmatically.true
to cause child menus to auto-open