com.google.gwt.user.client.ui
Class MenuBar

java.lang.Object
  extended bycom.google.gwt.user.client.ui.UIObject
      extended bycom.google.gwt.user.client.ui.Widget
          extended bycom.google.gwt.user.client.ui.MenuBar
All Implemented Interfaces:
EventListener, EventListener, PopupListener

public class MenuBar
extends Widget
implements PopupListener

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.

CSS Style Rules

Example

code


Field Summary
 
Fields inherited from class java.lang.Object
typeId, typeName
 
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(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(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(String text, Command cmd)
          Adds a menu item to the bar, that will fire the given command when it is selected.
 MenuItem addItem(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.
 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
getParent, isAttached, onAttach, onLoad
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, isVisible, isVisible, removeStyleName, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, finalize, hashCode
 

Constructor Detail

MenuBar

public MenuBar()
Creates an empty horizontal menu bar.


MenuBar

public MenuBar(boolean vertical)
Creates an empty menu bar.

Parameters:
vertical - true to orient the menu bar vertically
Method Detail

addItem

public void addItem(MenuItem item)
Adds a menu item to the bar.

Parameters:
item - the item to be added

addItem

public MenuItem addItem(String text,
                        boolean asHTML,
                        Command cmd)
Adds a menu item to the bar, that will fire the given command when it is selected.

Parameters:
text - the item's text
asHTML - true to treat the specified text as html
cmd - the command to be fired
Returns:
the MenuItem object created

addItem

public MenuItem addItem(String text,
                        boolean asHTML,
                        MenuBar popup)
Adds a menu item to the bar, that will open the specified menu when it is selected.

Parameters:
text - the item's text
asHTML - true to treat the specified text as html
popup - the menu to be cascaded from it
Returns:
the MenuItem object created

addItem

public MenuItem addItem(String text,
                        Command cmd)
Adds a menu item to the bar, that will fire the given command when it is selected.

Parameters:
text - the item's text
cmd - the command to be fired
Returns:
the MenuItem object created

addItem

public MenuItem addItem(String text,
                        MenuBar popup)
Adds a menu item to the bar, that will open the specified menu when it is selected.

Parameters:
text - the item's text
popup - the menu to be cascaded from it
Returns:
the MenuItem object created

clearItems

public void clearItems()
Removes all menu items from this menu bar.


getAutoOpen

public boolean getAutoOpen()
Gets whether this menu bar's child menus will open when the mouse is moved over it.

Returns:
true if child menus will auto-open

onBrowserEvent

public void onBrowserEvent(Event event)
Description copied from interface: EventListener
Fired whenever a browser event is received.

Specified by:
onBrowserEvent in interface EventListener
Overrides:
onBrowserEvent in class Widget

onPopupClosed

public void onPopupClosed(PopupPanel sender,
                          boolean autoClosed)
Description copied from interface: PopupListener
Fired when the popup is closed.

Specified by:
onPopupClosed in interface PopupListener
Parameters:
sender - popup being closed.
autoClosed - true if the popup was automatically closed; false if it was closed programmatically.

removeItem

public void removeItem(MenuItem item)
Removes the specified menu item from the bar.

Parameters:
item - the item to be removed

setAutoOpen

public void setAutoOpen(boolean autoOpen)
Sets whether this menu bar's child menus will open when the mouse is moved over it.

Parameters:
autoOpen - true to cause child menus to auto-open

onDetach

protected void onDetach()
Description copied from class: Widget
This method is called when a widget is detached from the browser's document. It must not be overridden, except by Panel.

Overrides:
onDetach in class Widget


This javadoc distribution was not produced by Google. The official documentation is here.