Package PamView

Class MenuItemEnabler

java.lang.Object
PamView.MenuItemEnabler

public class MenuItemEnabler extends Object
Now that there are many menus, there will several instances of each menu item. Each menu item may therefore be added to a MenuItemEnabler which will ensure that all items are enabled / disabled together.

Can also be used to setSelected

Reworked with a static list of all MenuItemEnablers so that when menus are removed from the system (which happens a lot !) they can be easily removed from all the Enablers.

Author:
Doug Gillespie
  • Constructor Details

    • MenuItemEnabler

      public MenuItemEnabler()
      Default constructor compiles a list of all MenuItemEnablers so that they can be cleaned up on mass
    • MenuItemEnabler

      public MenuItemEnabler(boolean initialState)
  • Method Details

    • removeMenuItemEnabler

      public void removeMenuItemEnabler()
    • removeMenuBar

      public static void removeMenuBar(JMenuBar menuBar)
      Call this for a menu that is no longer needed to remove all it's items from the enabler list.
      Parameters:
      menu - menu to be cleaned from menu enablers.
    • addMenuItem

      public void addMenuItem(AbstractButton newItem)
      Add a menu item to a menu item enabler.

      The menu items selected state and enabled state will be set immediately.

      Parameters:
      newItem - new menu item to manage.
    • removeMenuItem

      public void removeMenuItem(JMenuItem newItem)
    • removeMenuItem

      public void removeMenuItem(AbstractButton newItem)
    • enableItems

      public void enableItems(boolean enable)
      Enable all menu items in a MenuItemEnabler list
      Parameters:
      enable - enable or disable
    • selectItems

      public void selectItems(boolean select)
      Select all menu items in a MenuItemEnabler list
      Parameters:
      select - select or deselect
    • isEnabled

      public boolean isEnabled()
      Returns the currentEnabled state
      Returns:
      true if enabled
    • isSelected

      public boolean isSelected()
      Gets the current selected state for this enabler
      Returns:
      true if selected
    • getMenuItemList

      public Vector<AbstractButton> getMenuItemList()
      Returns:
      the menuItemList