Package PamView
Class MenuItemEnabler
java.lang.Object
PamView.MenuItemEnabler
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 Summary
ConstructorsConstructorDescriptionDefault constructor compiles a list of all MenuItemEnablers so that they can be cleaned up on massMenuItemEnabler(boolean initialState) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMenuItem(AbstractButton newItem) Add a menu item to a menu item enabler.voidenableItems(boolean enable) Enable all menu items in a MenuItemEnabler listbooleanReturns the currentEnabled statebooleanGets the current selected state for this enablerstatic voidremoveMenuBar(JMenuBar menuBar) Call this for a menu that is no longer needed to remove all it's items from the enabler list.voidremoveMenuItem(AbstractButton newItem) voidremoveMenuItem(JMenuItem newItem) voidvoidselectItems(boolean select) Select all menu items in a MenuItemEnabler list
-
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
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
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
-
removeMenuItem
-
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
- Returns:
- the menuItemList
-