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 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`.
  See Also:
    `PgGeometry_Menu`, `PsUpdateIf`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PsMethodMenu()` Constructor assigns the current language.

  - ### Method Summary

    Methods
    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()` Deprecated. Method is no longer used to decided about recreation of 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.
    `int` | `getPanelVersion()` Get panel version of this menubar to compare with panel version of PsConfig for decision if menubar needs to be recreated.
    `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.

    - ### Methods inherited from class java.util.Vector

      `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`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### PsMethodMenu

          public PsMethodMenu()

      Constructor assigns the current language.

  - ### 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 method `getParent()` to its classes.
      Specified by:
        `getFather` in interface `PsUpdateIf`
      See Also:
        `PsUpdateIf`, `update(Object)`, `setParent(PsUpdateIf)`

    - #### setParent

          public void setParent(PsUpdateIf aParent)

      Set parent to receive update methods.
      Specified by:
        `setParent` in interface `PsUpdateIf`
      Parameters:
        `aParent` - will receive events which `this` does 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:
        `getName` in interface `PsUpdateIf`

    - #### 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:
        `update` in interface `PsUpdateIf`
      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:
        `clone` in class `java.util.Vector`

    - #### 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

    - #### 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()`

    - #### actionPerformed

          public void actionPerformed(java.awt.event.ActionEvent event)

      Handle events related with menu items. Invoke method determined by current string and return `true` if event handled. Otherwise return `false` to give subclasses a chance to handle the event.
      Specified by:
        `actionPerformed` in interface `java.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:
        `itemStateChanged` in interface `java.awt.event.ItemListener`

    - #### applyMethod

          public boolean applyMethod(java.lang.String method)

      Invoke action determined by current string. This method returns `false`, and should be overwritten by subclasses.

    - #### getMenu

          public java.awt.Menu getMenu(java.lang.String menuName)

      Get a menu with given name. Return `menu` if menu exists.
      Parameters:
        `menuName` - Name of menu.

    - #### hasMenu

          public boolean hasMenu(java.lang.String menuName)

      Check existence of a menu with given name. Return `true` if 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 new `menu`.
      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 new `menu`.
      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. Return `menuItem` if 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. Return `true` if 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 new `menuItem` if menuItem is created.
      Parameters:
        `menuName` - Name of menu to which item will be added.
        `itemName` - Name of menu item.
        `shortcut` - Optional shortcut.

    - #### addMenuItem

          public java.awt.MenuItem addMenuItem(java.lang.String menuName,
                                      java.lang.String itemName)

      Create a new menuItem with given name. Return new `menuItem` if 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 new `menuItem` if 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.

"

The software JavaView? is copyright protected. All Rights Reserved.
"