public abstract class PsMethodMenu extends java.util.Vector implements java.awt.event.ActionListener, java.awt.event.ItemListener, PsUpdateIf
Each geometry may add a set of menu items to submenus of the 'method' menu.
Usage:
In the init()
method add new menu entries as follows:
addMenu("Menu-Name"); addMenuItem("Menu-Name", "Menu-Item-Name");The submenu is created if it does not exist. Catch menu events in the
applyMethod(String name)
using:
if (name.equals("Menu-Item-Name")) // invoke method related with "Menu-Item-Name".An application can be seen in
PgGeometry_Menu
.PgGeometry_Menu
,
PsUpdateIf
,
Serialized FormConstructor and Description |
---|
PsMethodMenu()
Constructor assigns the current language.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
Handle events related with menu items.
|
java.awt.Menu |
addMenu(java.lang.String menuName)
Create a new menu with given name, or return existing menu.
|
java.awt.Menu |
addMenu(java.lang.String parentLabel,
java.lang.String menuName)
Create a new menu with given name, or return existing menu.
|
java.awt.MenuItem |
addMenuItem(java.lang.String menuName,
java.lang.String itemName)
Create a new menuItem with given name.
|
java.awt.CheckboxMenuItem |
addMenuItem(java.lang.String menuName,
java.lang.String itemName,
boolean state)
Create a new checkboxMenuItem with given name.
|
java.awt.MenuItem |
addMenuItem(java.lang.String menuName,
java.lang.String itemName,
java.awt.MenuShortcut shortcut)
Create a new menuItem with given name.
|
boolean |
applyMethod(java.lang.String method)
Invoke action determined by current string.
|
java.lang.Object |
clone()
Duplicate menu by recursively cloning all instance variables
except inspector panels and lists of registered listeners.
|
PsUpdateIf |
getFather()
Get unique parent of an object.
|
java.lang.String |
getLanguage()
Get language used in this panel.
|
java.awt.Menu |
getMenu(java.lang.String menuName)
Get a menu with given name.
|
java.awt.MenuItem |
getMenuItem(java.lang.String menuName,
java.lang.String itemName)
Get a menuItem with given name.
|
java.lang.String |
getName()
Get name identifying the object.
|
boolean |
hasMenu(java.lang.String menuName)
Check existence of a menu with given name.
|
boolean |
hasMenuItem(java.lang.String menuName,
java.lang.String itemName)
Check existence of a menuItem with given name.
|
void |
init(PsObject object)
Register the target geometry, and
subclasses should register all menu items and submenus.
|
void |
itemStateChanged(java.awt.event.ItemEvent event)
Handle events related with checkbox menu items.
|
void |
removeMenu(java.lang.String menuName)
Remove menu with given name.
|
void |
removeMenuItem(java.lang.String menuName,
java.lang.String itemName)
Remove menuItem with given name.
|
void |
setName(java.lang.String aName)
Set name identifying the object.
|
void |
setParent(PsUpdateIf aParent)
Set parent to receive update methods.
|
boolean |
update(java.lang.Object event)
Update this menu if the parent object has changed.
|
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
public void init(PsObject object)
object
- argument used by subclasses to specify object on which action shall be executed.public PsUpdateIf getFather()
getParent()
to its classes.getFather
in interface PsUpdateIf
PsUpdateIf
,
update(Object)
,
setParent(PsUpdateIf)
public void setParent(PsUpdateIf aParent)
setParent
in interface PsUpdateIf
aParent
- will receive events which this
does not handlePsUpdateIf
,
update(Object)
,
getFather()
public void setName(java.lang.String aName)
public java.lang.String getName()
getName
in interface PsUpdateIf
public boolean update(java.lang.Object event)
update
in interface PsUpdateIf
event
- carries a lot of informationsetParent(PsUpdateIf)
,
getFather()
public java.lang.Object clone()
After cloning the init() method must be called to register the target geometry. The pointers to registered menu items are all removed, and in the latter call to init() recomputed.
clone
in class java.util.Vector
public java.lang.String getLanguage()
public void actionPerformed(java.awt.event.ActionEvent event)
true
if event handled. Otherwise return false
to give subclasses
a chance to handle the event.actionPerformed
in interface java.awt.event.ActionListener
public void itemStateChanged(java.awt.event.ItemEvent event)
itemStateChanged
in interface java.awt.event.ItemListener
public boolean applyMethod(java.lang.String method)
false
, and should be overwritten by subclasses.public java.awt.Menu getMenu(java.lang.String menuName)
menu
if menu exists.menuName
- Name of menu.public boolean hasMenu(java.lang.String menuName)
true
if menu exists.menuName
- Name of menu.public java.awt.Menu addMenu(java.lang.String menuName)
menu
.menuName
- Name of menu.public java.awt.Menu addMenu(java.lang.String parentLabel, java.lang.String menuName)
menu
.menuName
- Name of menu.public void removeMenu(java.lang.String menuName)
menuName
- Name of menu.public java.awt.MenuItem getMenuItem(java.lang.String menuName, java.lang.String itemName)
menuItem
if menuItem exists.menuName
- Name of menu to which which contains the item.itemName
- Name of menu item.public boolean hasMenuItem(java.lang.String menuName, java.lang.String itemName)
true
if menuItem exists.menuName
- Name of menu which contains the item.itemName
- Name of menu item.public java.awt.MenuItem addMenuItem(java.lang.String menuName, java.lang.String itemName, java.awt.MenuShortcut shortcut)
menuItem
if menuItem is created.menuName
- Name of menu to which item will be added.itemName
- Name of menu item.shortcut
- Optional shortcut.public java.awt.MenuItem addMenuItem(java.lang.String menuName, java.lang.String itemName)
menuItem
if menuItem is created.menuName
- Name of menu to which item will be added.itemName
- Name of menu item.public java.awt.CheckboxMenuItem addMenuItem(java.lang.String menuName, java.lang.String itemName, boolean state)
menuItem
if menuItem is created.menuName
- Name of menu to which item will be added.itemName
- Name of menu item.state
- Flag if item is switched on or off.public void removeMenuItem(java.lang.String menuName, java.lang.String itemName)
menuName
- Name of menu which which contains the item.itemName
- Name of menu item."