|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.MenuBar
public class MenuBar
A standard menu bar widget. A menu bar can contain any number of menu items,
each of which can either fire a Command or
open a cascaded menu bar.
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);
}
}
| Nested Class Summary | |
|---|---|
static interface |
MenuBar.MenuBarImages
An ImageBundle that provides images for MenuBar. |
| Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled |
| Field Summary |
|---|
| Fields inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
DEBUG_ID_PREFIX |
| Constructor Summary | |
|---|---|
MenuBar()
Creates an empty horizontal menu bar. |
|
MenuBar(boolean vertical)
Creates an empty menu bar. |
|
MenuBar(boolean vertical,
MenuBar.MenuBarImages images)
Creates an empty menu bar that uses the specified image bundle for menu images. |
|
MenuBar(MenuBar.MenuBarImages images)
Creates an empty horizontal menu bar that uses the specified image bundle for menu images. |
|
| Method Summary | |
|---|---|
MenuItem |
addItem(MenuItem item)
Adds a menu item to the bar. |
MenuItem |
addItem(java.lang.String text,
boolean asHTML,
Command cmd)
Adds a menu item to the bar, that will fire the given command when it is selected. |
MenuItem |
addItem(java.lang.String text,
boolean asHTML,
MenuBar popup)
Adds a menu item to the bar, that will open the specified menu when it is selected. |
MenuItem |
addItem(java.lang.String text,
Command cmd)
Adds a menu item to the bar, that will fire the given command when it is selected. |
MenuItem |
addItem(java.lang.String text,
MenuBar popup)
Adds a menu item to the bar, that will open the specified menu when it is selected. |
MenuItemSeparator |
addSeparator()
Adds a thin line to the MenuBar to separate sections of
MenuItems. |
MenuItemSeparator |
addSeparator(MenuItemSeparator separator)
Adds a thin line to the MenuBar to separate sections of
MenuItems. |
void |
clearItems()
Removes all menu items from this menu bar. |
boolean |
getAutoOpen()
Gets whether this menu bar's child menus will open when the mouse is moved over it. |
protected java.util.List<MenuItem> |
getItems()
Returns a list containing the MenuItem objects in the menu
bar. |
protected MenuItem |
getSelectedItem()
Returns the MenuItem that is currently selected
(highlighted) by the user. |
boolean |
isAnimationEnabled()
|
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received. |
protected void |
onDetach()
This method is called when a widget is detached from the browser's document. |
protected void |
onEnsureDebugId(java.lang.String baseID)
Affected Elements: -item# = the MenuItem at the specified index.
|
void |
onPopupClosed(PopupPanel sender,
boolean autoClosed)
Fired when the popup is closed. |
void |
removeItem(MenuItem item)
Removes the specified menu item from the bar. |
void |
removeSeparator(MenuItemSeparator separator)
Removes the specified MenuItemSeparator from the bar. |
void |
setAnimationEnabled(boolean enable)
Enable or disable animations. |
void |
setAutoOpen(boolean autoOpen)
Sets whether this menu bar's child menus will open when the mouse is moved over it. |
| Methods inherited from class com.google.gwt.user.client.ui.Widget |
|---|
doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onLoad, onUnload, removeFromParent |
| Methods inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MenuBar()
public MenuBar(MenuBar.MenuBarImages images)
images - a bundle that provides images for this menupublic MenuBar(boolean vertical)
vertical - true to orient the menu bar vertically
public MenuBar(boolean vertical,
MenuBar.MenuBarImages images)
vertical - true to orient the menu bar verticallyimages - a bundle that provides images for this menu| Method Detail |
|---|
public MenuItem addItem(MenuItem item)
item - the item to be added
MenuItem object
public MenuItem addItem(java.lang.String text,
boolean asHTML,
Command cmd)
text - the item's textasHTML - true to treat the specified text as htmlcmd - the command to be fired
MenuItem object created
public MenuItem addItem(java.lang.String text,
boolean asHTML,
MenuBar popup)
text - the item's textasHTML - true to treat the specified text as htmlpopup - the menu to be cascaded from it
MenuItem object created
public MenuItem addItem(java.lang.String text,
Command cmd)
text - the item's textcmd - the command to be fired
MenuItem object created
public MenuItem addItem(java.lang.String text,
MenuBar popup)
text - the item's textpopup - the menu to be cascaded from it
MenuItem object createdpublic MenuItemSeparator addSeparator()
MenuBar to separate sections of
MenuItems.
MenuItemSeparator object createdpublic MenuItemSeparator addSeparator(MenuItemSeparator separator)
MenuBar to separate sections of
MenuItems.
separator - the MenuItemSeparator to be added
MenuItemSeparator objectpublic void clearItems()
public boolean getAutoOpen()
true if child menus will auto-openpublic boolean isAnimationEnabled()
isAnimationEnabled in interface HasAnimationpublic void onBrowserEvent(Event event)
EventListener
onBrowserEvent in interface EventListeneronBrowserEvent in class Widgetevent - the event received
public void onPopupClosed(PopupPanel sender,
boolean autoClosed)
PopupListener
onPopupClosed in interface PopupListenersender - popup being closed.autoClosed - true if the popup was automatically
closed; false if it was closed programmatically.public void removeItem(MenuItem item)
item - the item to be removedpublic void removeSeparator(MenuItemSeparator separator)
MenuItemSeparator from the bar.
separator - the separator to be removedpublic void setAnimationEnabled(boolean enable)
HasAnimation
setAnimationEnabled in interface HasAnimationenable - true to enable, false to disablepublic void setAutoOpen(boolean autoOpen)
autoOpen - true to cause child menus to auto-openprotected java.util.List<MenuItem> getItems()
MenuItem 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
barprotected MenuItem getSelectedItem()
MenuItem 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 selectedprotected void onDetach()
WidgetWidget.onUnload() method.
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.
onDetach in class Widgetprotected void onEnsureDebugId(java.lang.String baseID)
MenuItem at the specified index.
onEnsureDebugId in class UIObjectbaseID - the base ID used by the main elementUIObject.onEnsureDebugId(String)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||