jv.objectGui
Class PsMethodMenu
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.Vector
-
- jv.objectGui.PsMethodMenu
-
- All Implemented Interfaces:
- java.awt.event.ActionListener, java.awt.event.ItemListener, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.EventListener, java.util.List, java.util.RandomAccess, PsUpdateIf
- Direct Known Subclasses:
- PgGeometry_Menu
public abstract class PsMethodMenu extends java.util.Vector implements java.awt.event.ActionListener, java.awt.event.ItemListener, PsUpdateIf
Add specific menu items to 'method' menu in control panel to invoke methods from menu. For example, each geometry may have a menu class derived this class which adds additional menu items and sub menus. When the geometry is the current geometry in the viewer, then its set of method menus is added to the menu bar of the control window.Each geometry may add a set of menu items to submenus of the 'method' menu.
Usage:
In theinit()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 theapplyMethod(String name)using:if (name.equals("Menu-Item-Name")) // invoke method related with "Menu-Item-Name".An application can be seen inPgGeometry_Menu.- See Also:
PgGeometry_Menu,PsUpdateIf, Serialized Form- Author:
- Konrad Polthier
- Version:
- 25.10.02, 2.70 revised (kp) Methods to insert menuItems at position added.
26.06.02, 2.60 revised (kp) Another method addMenuItem added which uses MenuShortcut.
01.01.01, 2.50 revised (kp) Implement PsUpdateIf to allow update if object has changed.
18.07.99, 2.00 revised (kp) Method calls changed and PsMenu replaced with standard java.awt.Menu.
00.00.98, 1.00 created (kp)
-
-
Constructor Summary
Constructors Constructor and Description PsMethodMenu()Constructor assigns the current language.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidactionPerformed(java.awt.event.ActionEvent event)Handle events related with menu items.java.awt.MenuaddMenu(java.lang.String menuName)Create a new menu with given name, or return existing menu.java.awt.MenuaddMenu(java.lang.String parentLabel, java.lang.String menuName)Create a new menu with given name, or return existing menu.java.awt.MenuItemaddMenuItem(java.lang.String menuName, java.lang.String itemName)Create a new menuItem with given name.java.awt.CheckboxMenuItemaddMenuItem(java.lang.String menuName, java.lang.String itemName, boolean state)Create a new checkboxMenuItem with given name.java.awt.MenuItemaddMenuItem(java.lang.String menuName, java.lang.String itemName, java.awt.MenuShortcut shortcut)Create a new menuItem with given name.booleanapplyMethod(java.lang.String method)Invoke action determined by current string.java.lang.Objectclone()Duplicate menu by recursively cloning all instance variables except inspector panels and lists of registered listeners.PsUpdateIfgetFather()Get unique parent of an object.java.lang.StringgetLanguage()Deprecated.Method is no longer used to decided about recreation of panel.java.awt.MenugetMenu(java.lang.String menuName)Get a menu with given name.java.awt.MenuItemgetMenuItem(java.lang.String menuName, java.lang.String itemName)Get a menuItem with given name.java.lang.StringgetName()Get name identifying the object.intgetPanelVersion()Get panel version of this menubar to compare with panel version of PsConfig for decision if menubar needs to be recreated.booleanhasMenu(java.lang.String menuName)Check existence of a menu with given name.booleanhasMenuItem(java.lang.String menuName, java.lang.String itemName)Check existence of a menuItem with given name.voidinit(PsObject object)Register the target geometry, and subclasses should register all menu items and submenus.voiditemStateChanged(java.awt.event.ItemEvent event)Handle events related with checkbox menu items.voidremoveMenu(java.lang.String menuName)Remove menu with given name.voidremoveMenuItem(java.lang.String menuName, java.lang.String itemName)Remove menuItem with given name.voidsetName(java.lang.String aName)Set name identifying the object.voidsetParent(PsUpdateIf aParent)Set parent to receive update methods.booleanupdate(java.lang.Object event)Update this menu if the parent object has changed.-
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeIf, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, toString, trimToSize
-
-
-
-
Method Detail
-
init
public void init(PsObject object)
Register the target geometry, and subclasses should register all menu items and submenus.- Parameters:
object- argument used by subclasses to specify object on which action shall be executed.
-
getFather
public PsUpdateIf getFather()
Get unique parent of an object. It was necessary to rename the method since Java 1.1. added a methodgetParent()to its classes.- Specified by:
getFatherin interfacePsUpdateIf- See Also:
PsUpdateIf,update(Object),setParent(PsUpdateIf)
-
setParent
public void setParent(PsUpdateIf aParent)
Set parent to receive update methods.- Specified by:
setParentin interfacePsUpdateIf- Parameters:
aParent- will receive events whichthisdoes not handle- See Also:
PsUpdateIf,update(Object),getFather()
-
setName
public void setName(java.lang.String aName)
Set name identifying the object. Should be chosen unique.
-
getName
public java.lang.String getName()
Get name identifying the object.- Specified by:
getNamein interfacePsUpdateIf
-
update
public boolean update(java.lang.Object event)
Update this menu if the parent object has changed. This method checks whether update is issued from parent. Subclasses may add functionality, for example, to set the state if CheckboxMenuItems.- Specified by:
updatein interfacePsUpdateIf- Parameters:
event- carries a lot of information- Returns:
- true if event has been handled, otherwise false
- See Also:
setParent(PsUpdateIf),getFather()
-
clone
public java.lang.Object clone()
Duplicate menu by recursively cloning all instance variables except inspector panels and lists of registered listeners.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.
- Overrides:
clonein classjava.util.Vector- Version:
- 21.10.00, 1.00 revised (kp)
21.10.00, 1.00 created (kp)
-
getPanelVersion
public int getPanelVersion()
Get panel version of this menubar to compare with panel version of PsConfig for decision if menubar needs to be recreated. Used, for example, when language of fonts have changed.- Since:
- JavaView 4.00.008
- Version:
- 12.11.12, 1.00 created (kp)
-
getLanguage
public java.lang.String getLanguage()
Deprecated. Method is no longer used to decided about recreation of panel.Get language used in this menubar.- See Also:
getPanelVersion()- Version:
- 12.11.12, 2.00 revised (kp) Method deprecated, use getPanelVersion.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event)
Handle events related with menu items. Invoke method determined by current string and returntrueif event handled. Otherwise returnfalseto give subclasses a chance to handle the event.- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener
-
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent event)
Handle events related with checkbox menu items. Might be called by checkbox menu items; method does nothing, all action must be done by subclass.- Specified by:
itemStateChangedin interfacejava.awt.event.ItemListener
-
applyMethod
public boolean applyMethod(java.lang.String method)
Invoke action determined by current string. This method returnsfalse, and should be overwritten by subclasses.
-
getMenu
public java.awt.Menu getMenu(java.lang.String menuName)
Get a menu with given name. Returnmenuif menu exists.- Parameters:
menuName- Name of menu.
-
hasMenu
public boolean hasMenu(java.lang.String menuName)
Check existence of a menu with given name. Returntrueif menu exists.- Parameters:
menuName- Name of menu.
-
addMenu
public java.awt.Menu addMenu(java.lang.String menuName)
Create a new menu with given name, or return existing menu. If menu already exists, just return it, else return newmenu.- Parameters:
menuName- Name of menu.
-
addMenu
public java.awt.Menu addMenu(java.lang.String parentLabel, java.lang.String menuName)Create a new menu with given name, or return existing menu. If menu already exists, just return it, else return newmenu.- Parameters:
menuName- Name of menu.
-
removeMenu
public void removeMenu(java.lang.String menuName)
Remove menu with given name.- Parameters:
menuName- Name of menu.
-
getMenuItem
public java.awt.MenuItem getMenuItem(java.lang.String menuName, java.lang.String itemName)Get a menuItem with given name. ReturnmenuItemif menuItem exists.- Parameters:
menuName- Name of menu to which which contains the item.itemName- Name of menu item.
-
hasMenuItem
public boolean hasMenuItem(java.lang.String menuName, java.lang.String itemName)Check existence of a menuItem with given name. Returntrueif menuItem exists.- Parameters:
menuName- Name of menu which contains the item.itemName- Name of menu item.
-
addMenuItem
public java.awt.MenuItem addMenuItem(java.lang.String menuName, java.lang.String itemName, java.awt.MenuShortcut shortcut)Create a new menuItem with given name. Return newmenuItemif menuItem is created.- Parameters:
menuName- Name of menu to which item will be added.itemName- Name of menu item.shortcut- Optional shortcut.- Version:
- 26.06.02, 1.00 created (kp)
-
addMenuItem
public java.awt.MenuItem addMenuItem(java.lang.String menuName, java.lang.String itemName)Create a new menuItem with given name. Return newmenuItemif menuItem is created.- Parameters:
menuName- Name of menu to which item will be added.itemName- Name of menu item.
-
addMenuItem
public java.awt.CheckboxMenuItem addMenuItem(java.lang.String menuName, java.lang.String itemName, boolean state)Create a new checkboxMenuItem with given name. Return newmenuItemif menuItem is created.- Parameters:
menuName- Name of menu to which item will be added.itemName- Name of menu item.state- Flag if item is switched on or off.
-
removeMenuItem
public void removeMenuItem(java.lang.String menuName, java.lang.String itemName)Remove menuItem with given name.- Parameters:
menuName- Name of menu which which contains the item.itemName- Name of menu item.
-
-
"