Class MenuItem
A widget that can be placed in a
MenuBar. Menu items can either fire a
Command when they are clicked, or open a
cascading sub-menu.
Constructors
Methods
Constructor Detail
MenuItem
Constructs a new menu item that fires a command when it is selected.
Parameters
- text
- the item's text
- cmd
- the command to be fired when it is selected
MenuItem
Constructs a new menu item that fires a 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 when it is selected
MenuItem
Constructs a new menu item that cascades to a sub-menu when it is selected.
Parameters
- text
- the item's text
- subMenu
- the sub-menu to be displayed when it is selected
MenuItem
Constructs a new menu item that cascades to a sub-menu when it is selected.
Parameters
- text
- the item's text
- asHTML
-
true
to treat the specified text as html
- subMenu
- the sub-menu to be displayed when it is selected
Method Detail
getCommand
Gets the command associated with this item.
Return Value
this item's command, or
null
if none exists
getHTML
Gets this object's contents as HTML.
Return Value
the object's HTML
getParentMenu
Gets the menu that contains this item.
Return Value
the parent menu, or
null
if none exists.
getSubMenu
Gets the sub-menu associated with this item.
Return Value
this item's sub-menu, or
null
if none exists
getText
Gets this object's text.
Return Value
the object's text
setCommand
public void
setCommand(
Command cmd)
Sets the command associated with this item.
Parameters
- cmd
- the command to be associated with this item
setHTML
public void
setHTML(
String html)
Sets this object's contents via HTML. Use care when setting an object's
HTML; it is an easy way to expose script-based security problems. Consider
using
setText(String) whenever possible.
Parameters
- html
- the object's new HTML
setSubMenu
public void
setSubMenu(
MenuBar subMenu)
Sets the sub-menu associated with this item.
Parameters
- subMenu
- this item's new sub-menu
setText
public void
setText(
String text)
Sets this object's text.
Parameters
- text
- the object's new text