|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.ui.MenuBar.MenuItem
public class MenuBar.MenuItem
A composite class for menu items and sub-menus. You can set commands to
be fired on user click by implementing the
MenuBar.Command
interface. You can also add
multiple MenuItems to a MenuItem and create a sub-menu.
Constructor Summary | |
---|---|
MenuBar.MenuItem(java.lang.String caption,
Resource icon,
MenuBar.Command command)
Constructs a new menu item that can optionally have an icon and a command associated with it. |
Method Summary | |
---|---|
MenuBar.MenuItem |
addItem(java.lang.String caption,
MenuBar.Command command)
Add a new item inside this item, thus creating a sub-menu. |
MenuBar.MenuItem |
addItem(java.lang.String caption,
Resource icon,
MenuBar.Command command)
Add a new item inside this item, thus creating a sub-menu. |
MenuBar.MenuItem |
addItemBefore(java.lang.String caption,
Resource icon,
MenuBar.Command command,
MenuBar.MenuItem itemToAddBefore)
Add an item before some item. |
MenuBar.MenuItem |
addSeparator()
Adds a separator to this menu. |
MenuBar.MenuItem |
addSeparatorBefore(MenuBar.MenuItem itemToAddBefore)
|
java.util.List<MenuBar.MenuItem> |
getChildren()
This will return the children of this item or null if there are none. |
MenuBar.Command |
getCommand()
For the associated command. |
java.lang.String |
getDescription()
Gets the items's description. |
Resource |
getIcon()
Gets the objects icon. |
int |
getId()
Get the unique identifier for this item. |
MenuBar.MenuItem |
getParent()
For the containing item. |
int |
getSize()
Returns the number of children. |
java.lang.String |
getStyleName()
|
java.lang.String |
getText()
Gets the objects text |
boolean |
hasChildren()
Checks if the item has children (if it is a sub-menu). |
boolean |
isCheckable()
Gets the checkable state of the item - whether the item has checked and unchecked states. |
boolean |
isChecked()
Gets the checked state of the item (checked or unchecked). |
boolean |
isEnabled()
|
boolean |
isSeparator()
|
boolean |
isVisible()
|
void |
removeChild(MenuBar.MenuItem item)
Remove the first occurrence of the item. |
void |
removeChildren()
Empty the list of children items. |
void |
setCheckable(boolean checkable)
Sets the checkable state of the item. |
void |
setChecked(boolean checked)
Sets the checked state of the item. |
void |
setCommand(MenuBar.Command command)
Set the command for this item. |
void |
setDescription(java.lang.String description)
Sets the items's description. |
void |
setEnabled(boolean enabled)
|
void |
setIcon(Resource icon)
Sets the icon. |
protected void |
setParent(MenuBar.MenuItem parent)
Set the parent of this item. |
void |
setStyleName(java.lang.String styleName)
|
void |
setText(java.lang.String text)
Set the text of this object. |
void |
setVisible(boolean visible)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MenuBar.MenuItem(java.lang.String caption, Resource icon, MenuBar.Command command)
text
- The text associated with the commandcommand
- The command to be fired
java.lang.IllegalArgumentException
Method Detail |
---|
public boolean hasChildren()
public MenuBar.MenuItem addSeparator()
public MenuBar.MenuItem addSeparatorBefore(MenuBar.MenuItem itemToAddBefore)
public MenuBar.MenuItem addItem(java.lang.String caption, MenuBar.Command command)
caption
- the text for the menu itemcommand
- the command for the menu itempublic MenuBar.MenuItem addItem(java.lang.String caption, Resource icon, MenuBar.Command command) throws java.lang.IllegalStateException
caption
- the text for the menu itemicon
- the icon for the menu itemcommand
- the command for the menu item
java.lang.IllegalStateException
- If the item is checkable and thus cannot have children.public MenuBar.MenuItem addItemBefore(java.lang.String caption, Resource icon, MenuBar.Command command, MenuBar.MenuItem itemToAddBefore) throws java.lang.IllegalStateException
caption
- the text for the menu itemicon
- the icon for the menu itemcommand
- the command for the menu itemitemToAddBefore
- the item that will be after the new item
java.lang.IllegalStateException
- If the item is checkable and thus cannot have children.public MenuBar.Command getCommand()
public Resource getIcon()
public MenuBar.MenuItem getParent()
MenuBar.MenuItem
, or
null if there is nonepublic java.util.List<MenuBar.MenuItem> getChildren()
public java.lang.String getText()
public int getSize()
public int getId()
public void setCommand(MenuBar.Command command)
command
- The MenuCommand of this itempublic void setIcon(Resource icon)
icon
- The icon for this itempublic void setText(java.lang.String text)
text
- Text for this objectpublic void removeChild(MenuBar.MenuItem item)
item
- The item to be removedpublic void removeChildren()
protected void setParent(MenuBar.MenuItem parent)
parent
- The parent itempublic void setEnabled(boolean enabled)
public boolean isEnabled()
public void setVisible(boolean visible)
public boolean isVisible()
public boolean isSeparator()
public void setStyleName(java.lang.String styleName)
public java.lang.String getStyleName()
public void setDescription(java.lang.String description)
getDescription()
for more
information on what the description is. This method will trigger a
RepaintRequestEvent
.
description
- the new description string for the component.public java.lang.String getDescription()
Gets the items's description. The description can be used to briefly describe the state of the item to the user. The description string may contain certain XML tags:
Tag | Description | Example |
<b> | bold | bold text |
<i> | italic | italic text |
<u> | underlined | underlined text |
<br> | linebreak | N/A |
<ul> <li>item1 <li>item1 </ul> |
item list |
|
These tags may be nested.
String
public boolean isCheckable()
isChecked()
) is indicated in the UI.
An item is not checkable by default.
public void setCheckable(boolean checkable) throws java.lang.IllegalStateException
isChecked()
) is indicated in
the UI.
An item is not checkable by default.
Items with sub items cannot be checkable.
checkable
- true if the item should be checkable, false otherwise
java.lang.IllegalStateException
- If the item has childrenpublic boolean isChecked()
isCheckable()
).
The checked state is indicated in the UI with the item, if the item
is checkable.
An item is not checked by default.
The CSS style corresponding to the checked state is "-checked".
public void setChecked(boolean checked)
isCheckable()
). The checked state is
indicated in the UI with the item, if the item is checkable.
An item is not checked by default.
The CSS style corresponding to the checked state is "-checked".
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |