Class MenuFactory
java.lang.Object
org.apache.batik.util.resources.ResourceManager
org.apache.batik.util.gui.resource.MenuFactory
This class represents a menu factory which builds
menubars and menus from the content of a resource file.
The resource entries format is (for a menubar named 'MenuBar'):
The resource entries format is (for a menubar named 'MenuBar'):
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 ButtonGroup- Version:
- $Id: MenuFactory.java 1804130 2017-08-04 14:41:11Z ssteiner $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private ActionMap
The table which contains the actionsprivate ButtonGroup
The current radio groupprivate static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
private static final String
Fields inherited from class org.apache.batik.util.resources.ResourceManager
bundle
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates and returns a new swing check box menu itemcreateJCheckBoxMenuItem
(String name, String specialization) Creates and returns a new swing check box menu itemcreateJMenu
(String name) Creates and returns a new swing menucreateJMenu
(String name, String specialization) Creates and returns a new swing menucreateJMenuBar
(String name) Creates and returns a swing menu barcreateJMenuBar
(String name, String specialization) Creates and returns a swing menu barprotected JComponent
createJMenuComponent
(String name, String specialization) Creates and returns a menu item or a separatorcreateJMenuItem
(String name) Creates and returns a new swing menu itemcreateJMenuItem
(String name, String specialization) Creates and returns a new swing menu itemCreates and returns a new swing radio button menu itemcreateJRadioButtonMenuItem
(String name, String specialization) Creates and returns a new swing radio button menu itemprotected 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 itemMethods inherited from class org.apache.batik.util.resources.ResourceManager
getBoolean, getCharacter, getInteger, getString, getStringList, getStringList, getStringList
-
Field Details
-
TYPE_MENU
- See Also:
-
TYPE_ITEM
- See Also:
-
TYPE_RADIO
- See Also:
-
TYPE_CHECK
- See Also:
-
SEPARATOR
- See Also:
-
TYPE_SUFFIX
- See Also:
-
TEXT_SUFFIX
- See Also:
-
MNEMONIC_SUFFIX
- See Also:
-
ACCELERATOR_SUFFIX
- See Also:
-
ACTION_SUFFIX
- See Also:
-
SELECTED_SUFFIX
- See Also:
-
ENABLED_SUFFIX
- See Also:
-
ICON_SUFFIX
- See Also:
-
actions
The table which contains the actions -
buttonGroup
The current radio group
-
-
Constructor Details
-
MenuFactory
Creates a new menu factory- Parameters:
rb
- the resource bundle that contains the menu bar description.am
- the actions to add to menu items
-
-
Method Details
-
createJMenuBar
public JMenuBar createJMenuBar(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a swing menu bar- Parameters:
name
- the name of the menu bar in the resource bundle- Throws:
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 map
-
createJMenuBar
public JMenuBar createJMenuBar(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a swing menu bar- Parameters:
name
- the name of the menu bar in the resource bundlespecialization
- the name of the specialization to look for- Throws:
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 map
-
getSpecializedString
Gets a possibly specialized resource string. This will first look forname + '.' + specialization
, and if that resource doesn't exist,name
. -
getSpecializedStringList
Gets a possibly specialized resource string list. This will first look forname + '.' + specialization
, and if that resource doesn't exist,name
. -
getSpecializedBoolean
Gets a possibly specialized resource boolean. This will first look forname + '.' + specialization
, and if that resource doesn't exist,name
. -
createJMenuComponent
protected JComponent createJMenuComponent(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a menu item or a separator- Parameters:
name
- the name of the menu item or "-" to create a separatorspecialization
- the name of the specialization to look for- Throws:
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 map
-
createJMenu
public JMenu createJMenu(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a new swing menu- Parameters:
name
- the name of the menu bar in the resource bundle- Throws:
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.
-
createJMenu
public JMenu createJMenu(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a new swing menu- Parameters:
name
- the name of the menu bar in the resource bundlespecialization
- the name of the specialization to look for- Throws:
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.
-
createJMenuItem
public JMenuItem createJMenuItem(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a new swing menu item- Parameters:
name
- the name of the menu item- Throws:
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.
-
createJMenuItem
public JMenuItem createJMenuItem(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a new swing menu item- Parameters:
name
- the name of the menu itemspecialization
- the name of the specialization to look for- Throws:
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.
-
createJRadioButtonMenuItem
public JRadioButtonMenuItem createJRadioButtonMenuItem(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a new swing radio button menu item- Parameters:
name
- the name of the menu item- Throws:
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.
-
createJRadioButtonMenuItem
public JRadioButtonMenuItem createJRadioButtonMenuItem(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a new swing radio button menu item- Parameters:
name
- the name of the menu itemspecialization
- the name of the specialization to look for- Throws:
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.
-
createJCheckBoxMenuItem
public JCheckBoxMenuItem createJCheckBoxMenuItem(String name) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a new swing check box menu item- Parameters:
name
- the name of the menu item- Throws:
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.
-
createJCheckBoxMenuItem
public JCheckBoxMenuItem createJCheckBoxMenuItem(String name, String specialization) throws MissingResourceException, ResourceFormatException, MissingListenerException Creates and returns a new swing check box menu item- Parameters:
name
- the name of the menu itemspecialization
- the name of the specialization to look for- Throws:
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.
-
initializeJMenuItem
protected void initializeJMenuItem(JMenuItem item, String name, String specialization) throws ResourceFormatException, MissingListenerException Initializes a swing menu item- Parameters:
item
- the menu item to initializename
- the name of the menu itemspecialization
- the name of the specialization to look for- Throws:
ResourceFormatException
- if the mnemonic is not a single character.MissingListenerException
- if then item action is not found in the action map.
-