|
|||||||||
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); } }
Constructor Summary | |
---|---|
MenuBar()
Creates an empty horizontal menu bar. |
|
MenuBar(boolean vertical)
Creates an empty menu bar. |
Method Summary | |
---|---|
void |
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. |
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 |
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. |
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. |
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 |
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, setElement |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, 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(boolean vertical)
vertical
- true
to orient the menu bar verticallyMethod Detail |
---|
public void addItem(MenuItem item)
item
- the item to be addedpublic 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 createdpublic 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 createdpublic MenuItem addItem(java.lang.String text, Command cmd)
text
- the item's textcmd
- the command to be fired
MenuItem
object createdpublic MenuItem addItem(java.lang.String text, MenuBar popup)
text
- the item's textpopup
- the menu to be cascaded from it
MenuItem
object createdpublic void clearItems()
public boolean getAutoOpen()
true
if child menus will auto-openpublic void onBrowserEvent(Event event)
EventListener
onBrowserEvent
in interface EventListener
onBrowserEvent
in class Widget
event
- the event receivedpublic void onPopupClosed(PopupPanel sender, boolean autoClosed)
PopupListener
onPopupClosed
in interface PopupListener
sender
- 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 setAutoOpen(boolean autoOpen)
autoOpen
- true
to cause child menus to auto-openprotected java.util.List 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()
Widget
Widget.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 Widget
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |