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 ButtonGroupbundle
Constructor and Description |
---|
MenuFactory(ResourceBundle rb,
ActionMap am)
Creates a new menu factory
|
Modifier and Type | Method and Description |
---|---|
JCheckBoxMenuItem |
createJCheckBoxMenuItem(String name)
Creates and returns a new swing check box menu item
|
JCheckBoxMenuItem |
createJCheckBoxMenuItem(String name,
String specialization)
Creates and returns a new swing check box menu item
|
JMenu |
createJMenu(String name)
Creates and returns a new swing menu
|
JMenu |
createJMenu(String name,
String specialization)
Creates and returns a new swing menu
|
JMenuBar |
createJMenuBar(String name)
Creates and returns a swing menu bar
|
JMenuBar |
createJMenuBar(String name,
String specialization)
Creates and returns a swing menu bar
|
protected JComponent |
createJMenuComponent(String name,
String specialization)
Creates and returns a menu item or a separator
|
JMenuItem |
createJMenuItem(String name)
Creates and returns a new swing menu item
|
JMenuItem |
createJMenuItem(String name,
String specialization)
Creates and returns a new swing menu item
|
JRadioButtonMenuItem |
createJRadioButtonMenuItem(String name)
Creates and returns a new swing radio button menu item
|
JRadioButtonMenuItem |
createJRadioButtonMenuItem(String name,
String specialization)
Creates and returns a new swing radio button menu item
|
protected boolean |
getSpecializedBoolean(String name,
String specialization)
Gets a possibly specialized resource boolean.
|
protected String |
getSpecializedString(String name,
String specialization)
Gets a possibly specialized resource string.
|
protected List |
getSpecializedStringList(String name,
String specialization)
Gets a possibly specialized resource string list.
|
protected void |
initializeJMenuItem(JMenuItem item,
String name,
String specialization)
Initializes a swing menu item
|
getBoolean, getCharacter, getInteger, getString, getStringList, getStringList, getStringList
public MenuFactory(ResourceBundle rb, ActionMap am)
rb
- the resource bundle that contains the menu bar
description.am
- the actions to add to menu itemspublic JMenuBar createJMenuBar(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu bar in the resource bundleMissingResourceException
- 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 JMenuBar createJMenuBar(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu bar in the resource bundlespecialization
- the name of the specialization to look forMissingResourceException
- 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 String getSpecializedString(String name, String specialization)
name + '.' + specialization
, and if that resource
doesn't exist, name
.protected List getSpecializedStringList(String name, String specialization)
name + '.' + specialization
, and if that resource
doesn't exist, name
.protected boolean getSpecializedBoolean(String name, String specialization)
name + '.' + specialization
, and if that resource
doesn't exist, name
.protected JComponent createJMenuComponent(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu item or "-" to create a separatorspecialization
- the name of the specialization to look forMissingResourceException
- 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 JMenu createJMenu(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu bar in the resource bundleMissingResourceException
- 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 JMenu createJMenu(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu bar in the resource bundlespecialization
- the name of the specialization to look forMissingResourceException
- 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 JMenuItem createJMenuItem(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemMissingResourceException
- 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 JMenuItem createJMenuItem(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemspecialization
- the name of the specialization to look forMissingResourceException
- 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 JRadioButtonMenuItem createJRadioButtonMenuItem(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemMissingResourceException
- 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 JRadioButtonMenuItem createJRadioButtonMenuItem(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemspecialization
- the name of the specialization to look forMissingResourceException
- 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 JCheckBoxMenuItem createJCheckBoxMenuItem(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemMissingResourceException
- 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 JCheckBoxMenuItem createJCheckBoxMenuItem(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException
name
- the name of the menu itemspecialization
- the name of the specialization to look forMissingResourceException
- 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(JMenuItem item, String name, 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.Copyright © 2000–2023 Apache Software Foundation. All rights reserved.