|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object O2Plib.gui.MenuSupport
public class MenuSupport
Class MenuSupport contains various Menu support functions for helping implement and support dynamic submenus of MenuItem or CheckboxMenuItem types. It tracks both entities in separate hash tables by either their associated command string or their MenuItem or CheckboxMenuItem instances. It supports radio groups using a common command name prefix ending in ':'. E.g., "Open:Sample:" with "Open:Sample:a1" "Open:Sample:a2" and "Open:Sample:a2" being in the same radio group. The event handler is in the parent calling these methods.
NOTE: event handlers are in the parent.
This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The Open2Dprot Mozilla and Legal files are available on http://open2dprot.sourceforge.net/
Nested Class Summary | |
---|---|
(package private) class |
MenuSupport.ChkBoxMenuData
|
(package private) class |
MenuSupport.MenuCmdData
|
Field Summary | |
---|---|
java.util.Hashtable |
chkBoxMenuItemCmdHT
Hashtable of ALL checkboxItem menu items. |
java.util.Hashtable |
chkBoxMenuItemDataHT
Hashtable of ALL checkboxItem menu items. |
static int |
MAX_CHKBOX_CMDS
max number of menu checkbox items allowed |
static int |
MAX_CMDS
Initial max number of menu items allowed. |
int |
maxCheckboxMenuItems
initial max number of menu checkbox items allowed |
int |
maxMenuItems
Initial max number of menu items allowed. |
java.util.Hashtable |
menuItemCmdHT
Hashtable of ALL menu items. |
java.util.Hashtable |
menuItemDataHT
Hashtable of ALL menu items. |
java.lang.String |
name
Name of this MenuSupport instance |
Constructor Summary | |
---|---|
MenuSupport()
MenuSupport() - Constructor. |
|
MenuSupport(java.lang.String name)
MenuSupport() - Constructor. |
|
MenuSupport(java.lang.String name,
int maxMenuItems,
int maxCheckboxMenuItems)
MenuSupport() - Constructor. |
Method Summary | |
---|---|
boolean |
clearSublistChkMenuItemStates(java.awt.CheckboxMenuItem cbmi)
clearSublistChkMenuItemStates() - clear all of the checkbox menu items in the radio group. |
boolean |
clearSublistChkMenuItemStates(java.lang.String preface)
clearSublistChkMenuItemStates() - clear all of the checkbox menu items in the radio group. |
java.lang.String[] |
getCmdListCBMIbyPreface(java.lang.String preface)
getCmdListCBMIbyPreface() - get list of all of the commands in the checkbox menu items with a common command prefix ending with a ':'. |
java.lang.String[] |
getMenuLabelListCBMIbyPreface(java.lang.String preface)
getMenuLabelListCBMIbyPreface() - get list of all of the menu labels in the checkbox menu items with a common command prefix endinting with a ':'. |
java.lang.String |
getRadioSublistChkMenuItemStates(java.awt.CheckboxMenuItem cbmi)
getRadioSublistChkMenuItemStates() - Do radio function by clearing all of the checkbox menu items except the one mentioned which is set to true. |
void |
init(java.lang.String name,
int maxMenuItems,
int maxCheckboxMenuItems)
init() - create empty hash tables. |
java.lang.String |
lookupChkboxMenuItem(java.awt.CheckboxMenuItem cbmi)
lookupChkboxMenuItem() - lookup String command entry in checkbox menu item list by searching (key,value)=(CheckboxMenuItem,ChkBoxMenuData) and returning the command if found. |
java.awt.CheckboxMenuItem |
lookupChkboxMenuItem(java.lang.String sCmd)
lookupChkboxMenuItem() - lookup CheckboxMenuItem entry in menu list by searching (key,value)=(cmd,ChkBoxMenuData) and returning the CheckboxMenuItem if found. |
java.lang.String |
lookupChkboxMenuItemLabel(java.lang.String sCmd)
lookupChkboxMenuItemLabel() - lookup CheckboxMenuItem entry label in menu list by searching (key,value)=(cmd,ChkBoxMenuData) and returning the menu label if found. |
java.lang.String |
lookupMenuItem(java.awt.MenuItem mi)
lookupMenuItem() - lookup MenuItem entry by MenuItem in menu list. |
java.awt.MenuItem |
lookupMenuItem(java.lang.String sCmd)
lookupMenuItem() - lookup MenuItem entry in menu list. |
java.lang.String |
lookupMenuItemLabel(java.lang.String sCmd)
lookupMenuItemLabel() - lookup CheckboxMenuItem entry label in menu list by searching (key,value)=(cmd,MenuCmdData) and returning the menu label if found. |
java.awt.CheckboxMenuItem |
makeChkBoxMenuItem(java.awt.Frame fm,
java.awt.Menu pm,
java.lang.String sLabel,
java.lang.String sCmd,
int shortcut,
boolean value)
makeChkBoxMenuItem() - make CheckboxMenuItem entry in popup menu list. |
java.awt.MenuItem |
makeMenuItem(java.awt.Frame fm,
java.awt.Menu pm,
java.lang.String sLabel,
java.lang.String sCmd,
int shortcut)
makeMenuItem() - make menuItem entry in menu list. |
java.awt.Menu |
makeSubMenu(java.awt.Frame fm,
java.awt.Menu pm,
java.lang.String sLabel,
java.lang.String sCmd,
int shortcut)
makeSubMenu() - make submenu entry in menu list. |
boolean |
rebuildChkBoxSubmenu(java.awt.Frame fm,
java.awt.Menu submenu,
java.lang.String preface,
java.lang.String[] entryList,
java.lang.String activeEntry)
rebuildChkBoxSubmenu() - rebuild a submenu with a new entry list indicated by menu labels from entryList[], the commands are preface+entryList[]. |
boolean |
setRadioSublistChkMenuItemStates(java.awt.CheckboxMenuItem cbmi)
setRadioSublistChkMenuItemStates() - Do radio function by clearing all of the checkbox menu items except the one mentioned which is set to true. |
boolean |
setRadioSublistChkMenuItemStates(java.lang.String sCmd)
setRadioSublistChkMenuItemStates() - Do radio function by clearing all of the checkbox menu items except the one mentioned which is set to true. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_CMDS
public static final int MAX_CHKBOX_CMDS
public int maxMenuItems
public int maxCheckboxMenuItems
public java.lang.String name
public java.util.Hashtable menuItemDataHT
public java.util.Hashtable menuItemCmdHT
public java.util.Hashtable chkBoxMenuItemDataHT
public java.util.Hashtable chkBoxMenuItemCmdHT
Constructor Detail |
---|
public MenuSupport()
public MenuSupport(java.lang.String name)
name
- of this menu support instancepublic MenuSupport(java.lang.String name, int maxMenuItems, int maxCheckboxMenuItems)
name
- of this menu support instancemaxMenuItems
- - initial maximum size of Menu Items in menubarmaxCheckboxMenuItems
- - initial maximum size of Checkbox Menu
Items in menubarMethod Detail |
---|
public void init(java.lang.String name, int maxMenuItems, int maxCheckboxMenuItems)
name
- of this menu support instancemaxMenuItems
- - initial maximum size of Menu Items in menubarmaxCheckboxMenuItems
- - initial maximum size of Checkbox Menu
Items in menubarpublic java.awt.MenuItem makeMenuItem(java.awt.Frame fm, java.awt.Menu pm, java.lang.String sLabel, java.lang.String sCmd, int shortcut)
fm
- is the frame that contains Action listener for this itempm
- is the menu to install new MenuItemsLabel
- is the visible labelsCmd
- is the opt Cmd name (uses sLabel if null)shortcut
- is the opt short cut
public java.awt.Menu makeSubMenu(java.awt.Frame fm, java.awt.Menu pm, java.lang.String sLabel, java.lang.String sCmd, int shortcut)
fm
- is the framepm
- is the menu to install new submenu insLabel
- is the visible labelsCmd
- is the opt Cmd name (uses sLabel if null)shortcut
- is the opt short cutpublic java.awt.CheckboxMenuItem makeChkBoxMenuItem(java.awt.Frame fm, java.awt.Menu pm, java.lang.String sLabel, java.lang.String sCmd, int shortcut, boolean value)
fm
- is the frame that contains Item listener for this itempm
- is the menu to install new CheckboxMenuItem insLabel
- is the visible labelsCmd
- is the opt Cmd name (uses sLabel if null)shortcut
- is the opt short cutvalue
- is the initial value of the checkboxpublic java.awt.MenuItem lookupMenuItem(java.lang.String sCmd)
sCmd
- is the opt Cmd name to search the hash table
for (key,value)=(cmd,MenuCmdData) and returning the MenuItem
if found.
public java.lang.String lookupMenuItem(java.awt.MenuItem mi)
mi
- is the MenuItem instance to searching the hash table
for (key,value)=(MenuItem,MenuCmdData) and returning the command
if found.miDataHT
- is the hash table storing
public java.awt.CheckboxMenuItem lookupChkboxMenuItem(java.lang.String sCmd)
sCmd
- is the opt Cmd name to search forcbmiCmdHT
- is the hash table storing
public java.lang.String lookupChkboxMenuItem(java.awt.CheckboxMenuItem cbmi)
cbmi
- is the CheckboxMenuItem to search for
public java.lang.String lookupMenuItemLabel(java.lang.String sCmd)
sCmd
- is the opt Cmd name to search for
public java.lang.String lookupChkboxMenuItemLabel(java.lang.String sCmd)
sCmd
- is the opt Cmd name to search for
public boolean clearSublistChkMenuItemStates(java.lang.String preface)
cbmi
- is the CheckboxMenuItem that is part of a radio group.
public boolean clearSublistChkMenuItemStates(java.awt.CheckboxMenuItem cbmi)
cbmi
- is the CheckboxMenuItem that is part of a radio group.
public boolean setRadioSublistChkMenuItemStates(java.lang.String sCmd)
sCmd
- is the command string for theCheckboxMenuItem that is
part of a radio group.
public boolean setRadioSublistChkMenuItemStates(java.awt.CheckboxMenuItem cbmi)
cbmi
- is the CheckboxMenuItem that is part of a radio group.
public java.lang.String getRadioSublistChkMenuItemStates(java.awt.CheckboxMenuItem cbmi)
cbmi
- is the CheckboxMenuItem that is part of a radio group.
public java.lang.String[] getCmdListCBMIbyPreface(java.lang.String preface)
cbmi
- is the CheckboxMenuItem that is part of a radio group.
public java.lang.String[] getMenuLabelListCBMIbyPreface(java.lang.String preface)
cbmi
- is the CheckboxMenuItem that is part of a radio group.
public boolean rebuildChkBoxSubmenu(java.awt.Frame fm, java.awt.Menu submenu, java.lang.String preface, java.lang.String[] entryList, java.lang.String activeEntry)
fm
- is the frame that contains this submenusubmenu
- to change contentspreface
- is added to each entry's command stringentryList
- of entries menu labels to addactiveEntry
- (if not null) to set true
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |