public class Menu
extends BaseUIObject
Menu
object represents a menu entry in the application menu bar, a contextual menu or a sub menu. A menu consist of a name, and contains
menu items which can be added or removed.Constructor and Description |
---|
Menu(java.lang.String name)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addMenuItem(int index,
MenuItem item)
Adds a menu item at the specified index.
|
void |
addMenuItem(MenuItem item)
Adds a menu item at the end of the menu.
|
void |
addSeparator()
Adds a separator at the end of the menu.
|
void |
addSeparator(int index)
Adds a separator at the specified index.
|
void |
addSubMenu(int index,
Menu subMenu)
Adds a sub menu at the specified index.
|
void |
addSubMenu(Menu subMenu)
Adds a sub menu at the end of the menu.
|
int |
countMenuItems()
Returns the number of menu items in this menu.
|
MenuItem |
findMenuItem(int command)
Returns a menu item based on it's command.
|
int |
getID()
Returns the menu ID.
|
MenuItem |
getMenuItem(int index)
Returns a menu item by index.
|
MenuItem |
getMenuItem(java.lang.String name)
Returns a menu item by name.
|
MenuItem |
getMenuItemByID(int command)
Returns a menu item by ID.
|
java.lang.String |
getName()
Returns the menu name.
|
java.lang.Object |
getParent()
Returns the parent object for this object.
|
boolean |
isEnabled()
Returns the state of this menu.
|
void |
removeMenuItem(MenuItem item)
Removes a menu item.
|
void |
removeMenuItemAt(int index)
Removes a menu item by index.
|
void |
removeMenuItemByID(int command)
Removes a menu item by ID.
|
void |
setEnabled(boolean bEnabled)
Enables or disables a menu.
|
void |
setName(java.lang.String name)
Sets the menu name.
|
public Menu(java.lang.String name)
name
- the menu title as it appears in the menu bar.public int countMenuItems()
public MenuItem getMenuItem(int index)
index
- the index of the menu item.public MenuItem getMenuItem(java.lang.String name) throws CumulusException
name
- the menu item name.CumulusException
- if the specified item name doesn't exits.MenuItem.getName()
public MenuItem findMenuItem(int command)
command
- the menu item command.null
if no such item exists in the menu.public MenuItem getMenuItemByID(int command) throws CumulusException
MenuItem.getCommand()
.command
- the menu item ID.CumulusException
- if the specified item ID doesn't exits.public void addMenuItem(MenuItem item)
class MyClass implements ActionHandler { ... MenuItem item = new MenuItem("MyItem"); item.setActionCommand("MyCommand"); item.setActionHandler(this); Application.getInstance().getMenuBar().getMenu(Application.MENU_MID_FILE_MENU).addMenuItem(item); ... }
item
- the menu item to add.public void addMenuItem(int index, MenuItem item)
index
- the index of the menu item to add.item
- the menu item to add.public void addSeparator()
public void addSeparator(int index)
index
- the index of the separator to add.public void addSubMenu(Menu subMenu)
class MyClass implements ActionHandler { ... Menu menu = new Menu("MyMenu"); MenuItem item = new MenuItem("MyItem"); ... menu.addMenuItem(item); Application.getInstance().getMenuBar().getMenu(Application.MENU_MID_FILE_MENU).addSubMenu(menu); ... }
subMenu
- the sub menu to add.public void addSubMenu(int index, Menu subMenu)
index
- the index of the sub menu to add.subMenu
- the sub menu to add.public void removeMenuItem(MenuItem item) throws CumulusException
item
- the menu item to remove.CumulusException
- the specified item is not in the menu.public void removeMenuItemAt(int index)
index
- the index of the item to remove.public void removeMenuItemByID(int command) throws CumulusException
command
- the ID of the item to remove.CumulusException
- the specified item is not in the menu.public java.lang.String getName()
public void setName(java.lang.String name)
name
- the menu name.public boolean isEnabled()
true
if the menu is enabled; false
otherwise.public void setEnabled(boolean bEnabled)
bEnabled
- true
if the menu should be enabled; false
otherwise.public int getID()
www.canto.com
Canto, the Canto logo, the Cumulus logo, and Cumulus are registered trademarks of Canto GmbH, registered in the U.S. and other countries.