
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. |
| 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-opentrue if the popup was automatically
closed; false if it was closed programmatically.true to cause child menus to auto-open