com.extjs.gxt.ui.client.widget.menu
Class MenuItem

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.menu.Item
                  extended by com.extjs.gxt.ui.client.widget.menu.MenuItem
All Implemented Interfaces:
Observable, IconSupport, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener
Direct Known Subclasses:
CheckMenuItem

public class MenuItem
extends Item
implements IconSupport

A base class for all menu items that require menu-related functionality (like sub-menus) and are not static display items. Item extends the base functionality of Item by adding menu-specific activation and click handling.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
MenuItem()
          Creates a new item.
MenuItem(java.lang.String text)
          Creates a new item with the given text.
MenuItem(java.lang.String text, com.google.gwt.user.client.ui.AbstractImagePrototype icon)
          Creates a new item.
MenuItem(java.lang.String text, com.google.gwt.user.client.ui.AbstractImagePrototype icon, SelectionListener<? extends MenuEvent> listener)
          Creates a new item.
MenuItem(java.lang.String text, SelectionListener<? extends MenuEvent> listener)
          Creates a new item.
 
Method Summary
 void expandMenu()
          Expands the item's sub menu.
 com.google.gwt.user.client.ui.AbstractImagePrototype getIcon()
          Returns the item's icon style.
 Menu getSubMenu()
          Returns the item's sub menu.
 java.lang.String getText()
          Returns the item's text.
 void setIcon(com.google.gwt.user.client.ui.AbstractImagePrototype icon)
          Sets the item's icon style.
 void setIconStyle(java.lang.String icon)
          Sets the icon style.
 void setSubMenu(Menu menu)
          Sets the item's sub menu.
 void setText(java.lang.String text)
          Sets the item's text.
 
Methods inherited from class com.extjs.gxt.ui.client.widget.menu.Item
addSelectionListener, getActiveStyle, getHideOnClick, getParentMenu, removeSelectionListener, setActiveStyle, setHideOnClick
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addListener, addPlugin, addStyleName, addWidgetListener, clearState, disable, disableEvents, disableTextSelection, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, getBaseStyle, getBorders, getContextMenu, getData, getElement, getHideMode, getId, getItemId, getListeners, getModel, getState, getStateId, getToolTip, hasListeners, hasListeners, hide, hideToolTip, isDisabledEvents, isEnabled, isRendered, isStateful, isVisible, mask, mask, mask, onBrowserEvent, onComponentEvent, recalculate, removeAllListeners, removeFromParent, removeListener, removeStyleName, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setBorders, setContextMenu, setData, setElement, setEnabled, setHeight, setHideMode, setId, setIntStyleAttribute, setItemId, setPixelSize, setSize, setStateful, setStateId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, setWidth, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
fireEvent, getParent, isAttached
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, setStylePrimaryName, setVisible, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MenuItem

public MenuItem()
Creates a new item.


MenuItem

public MenuItem(java.lang.String text)
Creates a new item with the given text.

Parameters:
text - the item's text

MenuItem

public MenuItem(java.lang.String text,
                SelectionListener<? extends MenuEvent> listener)
Creates a new item.

Parameters:
text - the item text
listener - the selection listener

MenuItem

public MenuItem(java.lang.String text,
                com.google.gwt.user.client.ui.AbstractImagePrototype icon)
Creates a new item.

Parameters:
text - the item's text
icon - the item's icon

MenuItem

public MenuItem(java.lang.String text,
                com.google.gwt.user.client.ui.AbstractImagePrototype icon,
                SelectionListener<? extends MenuEvent> listener)
Creates a new item.

Parameters:
text - the item's text
icon - the item's icon
listener - the selection listener
Method Detail

expandMenu

public void expandMenu()
Expands the item's sub menu.


getIcon

public com.google.gwt.user.client.ui.AbstractImagePrototype getIcon()
Returns the item's icon style.

Specified by:
getIcon in interface IconSupport
Returns:
the icon style

getSubMenu

public Menu getSubMenu()
Returns the item's sub menu.

Returns:
the sub menu

getText

public java.lang.String getText()
Returns the item's text.

Returns:
the text

setIcon

public void setIcon(com.google.gwt.user.client.ui.AbstractImagePrototype icon)
Sets the item's icon style. The style name should match a CSS style that specifies a background image using the following format:
 <code>
 .my-icon {
    background: url(images/icons/my-icon.png) no-repeat center left !important;
 }
 </code>
 

Specified by:
setIcon in interface IconSupport
Parameters:
icon - the icon

setIconStyle

public void setIconStyle(java.lang.String icon)
Description copied from interface: IconSupport
Sets the icon style.

Specified by:
setIconStyle in interface IconSupport
Parameters:
icon - a CSS style name

setSubMenu

public void setSubMenu(Menu menu)
Sets the item's sub menu.

Parameters:
menu - the sub menu

setText

public void setText(java.lang.String text)
Sets the item's text.

Parameters:
text - the text