public class MenuFactory extends ResourceManager
MenuBar = Menu1 Menu2 ...
Menu1.type = RADIO | CHECK | MENU | ITEM
Menu1 = Item1 Item2 - Item3 ...
Menu1.text = text
Menu1.icon = icon_name
Menu1.mnemonic = mnemonic
Menu1.accelerator = accelerator
Menu1.action = action_name
Menu1.selected = true | false
Menu1.enabled = true | false
...
mnemonic is a single character
accelerator is of the form described in KeyStroke.getKeyStroke(String)
.
'-' represents a separator
All entries are optional except the '.type' entry
Consecutive RADIO items are put in a ButtonGroupModifier and Type | Field and Description |
---|---|
private static java.lang.String |
ACCELERATOR_SUFFIX |
private static java.lang.String |
ACTION_SUFFIX |
private ActionMap |
actions
The table which contains the actions
|
private javax.swing.ButtonGroup |
buttonGroup
The current radio group
|
private static java.lang.String |
ENABLED_SUFFIX |
private static java.lang.String |
ICON_SUFFIX |
private static java.lang.String |
MNEMONIC_SUFFIX |
private static java.lang.String |
SELECTED_SUFFIX |
private static java.lang.String |
SEPARATOR |
private static java.lang.String |
TEXT_SUFFIX |
private static java.lang.String |
TYPE_CHECK |
private static java.lang.String |
TYPE_ITEM |
private static java.lang.String |
TYPE_MENU |
private static java.lang.String |
TYPE_RADIO |
private static java.lang.String |
TYPE_SUFFIX |
bundle
Constructor and Description |
---|
MenuFactory(java.util.ResourceBundle rb,
ActionMap am)
Creates a new menu factory
|
Modifier and Type | Method and Description |
---|---|
javax.swing.JCheckBoxMenuItem |
createJCheckBoxMenuItem(java.lang.String name)
Creates and returns a new swing check box menu item
|
javax.swing.JCheckBoxMenuItem |
createJCheckBoxMenuItem(java.lang.String name,
java.lang.String specialization)
Creates and returns a new swing check box menu item
|
javax.swing.JMenu |
createJMenu(java.lang.String name)
Creates and returns a new swing menu
|
javax.swing.JMenu |
createJMenu(java.lang.String name,
java.lang.String specialization)
Creates and returns a new swing menu
|
javax.swing.JMenuBar |
createJMenuBar(java.lang.String name)
Creates and returns a swing menu bar
|
javax.swing.JMenuBar |
createJMenuBar(java.lang.String name,
java.lang.String specialization)
Creates and returns a swing menu bar
|
protected javax.swing.JComponent |
createJMenuComponent(java.lang.String name,
java.lang.String specialization)
Creates and returns a menu item or a separator
|
javax.swing.JMenuItem |
createJMenuItem(java.lang.String name)
Creates and returns a new swing menu item
|
javax.swing.JMenuItem |
createJMenuItem(java.lang.String name,
java.lang.String specialization)
Creates and returns a new swing menu item
|
javax.swing.JRadioButtonMenuItem |
createJRadioButtonMenuItem(java.lang.String name)
Creates and returns a new swing radio button menu item
|
javax.swing.JRadioButtonMenuItem |
createJRadioButtonMenuItem(java.lang.String name,
java.lang.String specialization)
Creates and returns a new swing radio button menu item
|
protected boolean |
getSpecializedBoolean(java.lang.String name,
java.lang.String specialization)
Gets a possibly specialized resource boolean.
|
protected java.lang.String |
getSpecializedString(java.lang.String name,
java.lang.String specialization)
Gets a possibly specialized resource string.
|
protected java.util.List |
getSpecializedStringList(java.lang.String name,
java.lang.String specialization)
Gets a possibly specialized resource string list.
|
protected void |
initializeJMenuItem(javax.swing.JMenuItem item,
java.lang.String name,
java.lang.String specialization)
Initializes a swing menu item
|
getBoolean, getCharacter, getInteger, getString, getStringList, getStringList, getStringList
private static final java.lang.String TYPE_MENU
private static final java.lang.String TYPE_ITEM
private static final java.lang.String TYPE_RADIO
private static final java.lang.String TYPE_CHECK
private static final java.lang.String SEPARATOR
private static final java.lang.String TYPE_SUFFIX
private static final java.lang.String TEXT_SUFFIX
private static final java.lang.String MNEMONIC_SUFFIX
private static final java.lang.String ACCELERATOR_SUFFIX
private static final java.lang.String ACTION_SUFFIX
private static final java.lang.String SELECTED_SUFFIX
private static final java.lang.String ENABLED_SUFFIX
private static final java.lang.String ICON_SUFFIX
private ActionMap actions
private javax.swing.ButtonGroup buttonGroup
public MenuFactory(java.util.ResourceBundle rb, ActionMap am)
rb
- the resource bundle that contains the menu bar
description.am
- the actions to add to menu itemspublic javax.swing.JMenuBar createJMenuBar(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu bar in the resource bundlejava.util.MissingResourceException
- if one of the keys that compose the
menu is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character and if the accelerator is malformedMissingListenerException
- if an item action is not found in the
action mappublic javax.swing.JMenuBar createJMenuBar(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu bar in the resource bundlespecialization
- the name of the specialization to look forjava.util.MissingResourceException
- if one of the keys that compose the
menu is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character and if the accelerator is malformedMissingListenerException
- if an item action is not found in the
action mapprotected java.lang.String getSpecializedString(java.lang.String name, java.lang.String specialization)
name + '.' + specialization
, and if that resource
doesn't exist, name
.protected java.util.List getSpecializedStringList(java.lang.String name, java.lang.String specialization)
name + '.' + specialization
, and if that resource
doesn't exist, name
.protected boolean getSpecializedBoolean(java.lang.String name, java.lang.String specialization)
name + '.' + specialization
, and if that resource
doesn't exist, name
.protected javax.swing.JComponent createJMenuComponent(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu item or "-" to create a separatorspecialization
- the name of the specialization to look forjava.util.MissingResourceException
- if key is not the name of a menu item.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- in case of malformed entryMissingListenerException
- if an item action is not found in the
action mappublic javax.swing.JMenu createJMenu(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu bar in the resource bundlejava.util.MissingResourceException
- if one of the keys that compose the
menu is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character.MissingListenerException
- if a item action is not found in the
action map.public javax.swing.JMenu createJMenu(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu bar in the resource bundlespecialization
- the name of the specialization to look forjava.util.MissingResourceException
- if one of the keys that compose the
menu is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character.MissingListenerException
- if a item action is not found in the
action map.public javax.swing.JMenuItem createJMenuItem(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemjava.util.MissingResourceException
- if one of the keys that compose the
menu item is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character.MissingListenerException
- if then item action is not found in
the action map.public javax.swing.JMenuItem createJMenuItem(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemspecialization
- the name of the specialization to look forjava.util.MissingResourceException
- if one of the keys that compose the
menu item is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character.MissingListenerException
- if then item action is not found in
the action map.public javax.swing.JRadioButtonMenuItem createJRadioButtonMenuItem(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemjava.util.MissingResourceException
- if one of the keys that compose the
menu item is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character.MissingListenerException
- if then item action is not found in
the action map.public javax.swing.JRadioButtonMenuItem createJRadioButtonMenuItem(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemspecialization
- the name of the specialization to look forjava.util.MissingResourceException
- if one of the keys that compose the
menu item is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character.MissingListenerException
- if then item action is not found in
the action map.public javax.swing.JCheckBoxMenuItem createJCheckBoxMenuItem(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemjava.util.MissingResourceException
- if one of the keys that compose the
menu item is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character.MissingListenerException
- if then item action is not found in
the action map.public javax.swing.JCheckBoxMenuItem createJCheckBoxMenuItem(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemspecialization
- the name of the specialization to look forjava.util.MissingResourceException
- if one of the keys that compose the
menu item is missing.
It is not thrown if the mnemonic, the accelerator and the
action keys are missingResourceFormatException
- if the mnemonic is not a single
character.MissingListenerException
- if then item action is not found in
the action map.protected void initializeJMenuItem(javax.swing.JMenuItem item, java.lang.String name, java.lang.String specialization) throws ResourceFormatException, MissingListenerException
item
- the menu item to initializename
- the name of the menu itemspecialization
- the name of the specialization to look forResourceFormatException
- if the mnemonic is not a single
character.MissingListenerException
- if then item action is not found in
the action map.