Class MenuFactory
- java.lang.Object
-
- org.apache.batik.util.resources.ResourceManager
-
- org.apache.batik.util.gui.resource.MenuFactory
-
public class MenuFactory extends ResourceManager
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'):
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
All entries are optional except the '.type' entry Consecutive RADIO items are put in a ButtonGroupKeyStroke.getKeyStroke(String). '-' represents a separator- Version:
- $Id: MenuFactory.java 1804130 2017-08-04 14:41:11Z ssteiner $
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringACCELERATOR_SUFFIXprivate static java.lang.StringACTION_SUFFIXprivate ActionMapactionsThe table which contains the actionsprivate javax.swing.ButtonGroupbuttonGroupThe current radio groupprivate static java.lang.StringENABLED_SUFFIXprivate static java.lang.StringICON_SUFFIXprivate static java.lang.StringMNEMONIC_SUFFIXprivate static java.lang.StringSELECTED_SUFFIXprivate static java.lang.StringSEPARATORprivate static java.lang.StringTEXT_SUFFIXprivate static java.lang.StringTYPE_CHECKprivate static java.lang.StringTYPE_ITEMprivate static java.lang.StringTYPE_MENUprivate static java.lang.StringTYPE_RADIOprivate static java.lang.StringTYPE_SUFFIX-
Fields inherited from class org.apache.batik.util.resources.ResourceManager
bundle
-
-
Constructor Summary
Constructors Constructor Description MenuFactory(java.util.ResourceBundle rb, ActionMap am)Creates a new menu factory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.swing.JCheckBoxMenuItemcreateJCheckBoxMenuItem(java.lang.String name)Creates and returns a new swing check box menu itemjavax.swing.JCheckBoxMenuItemcreateJCheckBoxMenuItem(java.lang.String name, java.lang.String specialization)Creates and returns a new swing check box menu itemjavax.swing.JMenucreateJMenu(java.lang.String name)Creates and returns a new swing menujavax.swing.JMenucreateJMenu(java.lang.String name, java.lang.String specialization)Creates and returns a new swing menujavax.swing.JMenuBarcreateJMenuBar(java.lang.String name)Creates and returns a swing menu barjavax.swing.JMenuBarcreateJMenuBar(java.lang.String name, java.lang.String specialization)Creates and returns a swing menu barprotected javax.swing.JComponentcreateJMenuComponent(java.lang.String name, java.lang.String specialization)Creates and returns a menu item or a separatorjavax.swing.JMenuItemcreateJMenuItem(java.lang.String name)Creates and returns a new swing menu itemjavax.swing.JMenuItemcreateJMenuItem(java.lang.String name, java.lang.String specialization)Creates and returns a new swing menu itemjavax.swing.JRadioButtonMenuItemcreateJRadioButtonMenuItem(java.lang.String name)Creates and returns a new swing radio button menu itemjavax.swing.JRadioButtonMenuItemcreateJRadioButtonMenuItem(java.lang.String name, java.lang.String specialization)Creates and returns a new swing radio button menu itemprotected booleangetSpecializedBoolean(java.lang.String name, java.lang.String specialization)Gets a possibly specialized resource boolean.protected java.lang.StringgetSpecializedString(java.lang.String name, java.lang.String specialization)Gets a possibly specialized resource string.protected java.util.ListgetSpecializedStringList(java.lang.String name, java.lang.String specialization)Gets a possibly specialized resource string list.protected voidinitializeJMenuItem(javax.swing.JMenuItem item, java.lang.String name, java.lang.String specialization)Initializes a swing menu item-
Methods inherited from class org.apache.batik.util.resources.ResourceManager
getBoolean, getCharacter, getInteger, getString, getStringList, getStringList, getStringList
-
-
-
-
Field Detail
-
TYPE_MENU
private static final java.lang.String TYPE_MENU
- See Also:
- Constant Field Values
-
TYPE_ITEM
private static final java.lang.String TYPE_ITEM
- See Also:
- Constant Field Values
-
TYPE_RADIO
private static final java.lang.String TYPE_RADIO
- See Also:
- Constant Field Values
-
TYPE_CHECK
private static final java.lang.String TYPE_CHECK
- See Also:
- Constant Field Values
-
SEPARATOR
private static final java.lang.String SEPARATOR
- See Also:
- Constant Field Values
-
TYPE_SUFFIX
private static final java.lang.String TYPE_SUFFIX
- See Also:
- Constant Field Values
-
TEXT_SUFFIX
private static final java.lang.String TEXT_SUFFIX
- See Also:
- Constant Field Values
-
MNEMONIC_SUFFIX
private static final java.lang.String MNEMONIC_SUFFIX
- See Also:
- Constant Field Values
-
ACCELERATOR_SUFFIX
private static final java.lang.String ACCELERATOR_SUFFIX
- See Also:
- Constant Field Values
-
ACTION_SUFFIX
private static final java.lang.String ACTION_SUFFIX
- See Also:
- Constant Field Values
-
SELECTED_SUFFIX
private static final java.lang.String SELECTED_SUFFIX
- See Also:
- Constant Field Values
-
ENABLED_SUFFIX
private static final java.lang.String ENABLED_SUFFIX
- See Also:
- Constant Field Values
-
ICON_SUFFIX
private static final java.lang.String ICON_SUFFIX
- See Also:
- Constant Field Values
-
actions
private ActionMap actions
The table which contains the actions
-
buttonGroup
private javax.swing.ButtonGroup buttonGroup
The current radio group
-
-
Constructor Detail
-
MenuFactory
public MenuFactory(java.util.ResourceBundle rb, ActionMap am)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 Detail
-
createJMenuBar
public javax.swing.JMenuBar createJMenuBar(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates and returns a swing menu bar- Parameters:
name- the name of the menu bar in the resource bundle- Throws:
java.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 map
-
createJMenuBar
public javax.swing.JMenuBar createJMenuBar(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates 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:
java.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 map
-
getSpecializedString
protected java.lang.String getSpecializedString(java.lang.String name, java.lang.String specialization)Gets a possibly specialized resource string. This will first look forname + '.' + specialization, and if that resource doesn't exist,name.
-
getSpecializedStringList
protected java.util.List getSpecializedStringList(java.lang.String name, java.lang.String specialization)Gets a possibly specialized resource string list. This will first look forname + '.' + specialization, and if that resource doesn't exist,name.
-
getSpecializedBoolean
protected boolean getSpecializedBoolean(java.lang.String name, java.lang.String specialization)Gets a possibly specialized resource boolean. This will first look forname + '.' + specialization, and if that resource doesn't exist,name.
-
createJMenuComponent
protected javax.swing.JComponent createJMenuComponent(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates 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:
java.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 map
-
createJMenu
public javax.swing.JMenu createJMenu(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates and returns a new swing menu- Parameters:
name- the name of the menu bar in the resource bundle- Throws:
java.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.
-
createJMenu
public javax.swing.JMenu createJMenu(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates 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:
java.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.
-
createJMenuItem
public javax.swing.JMenuItem createJMenuItem(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates and returns a new swing menu item- Parameters:
name- the name of the menu item- Throws:
java.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.
-
createJMenuItem
public javax.swing.JMenuItem createJMenuItem(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates and returns a new swing menu item- Parameters:
name- the name of the menu itemspecialization- the name of the specialization to look for- Throws:
java.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.
-
createJRadioButtonMenuItem
public javax.swing.JRadioButtonMenuItem createJRadioButtonMenuItem(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates and returns a new swing radio button menu item- Parameters:
name- the name of the menu item- Throws:
java.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.
-
createJRadioButtonMenuItem
public javax.swing.JRadioButtonMenuItem createJRadioButtonMenuItem(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates 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:
java.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.
-
createJCheckBoxMenuItem
public javax.swing.JCheckBoxMenuItem createJCheckBoxMenuItem(java.lang.String name) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates and returns a new swing check box menu item- Parameters:
name- the name of the menu item- Throws:
java.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.
-
createJCheckBoxMenuItem
public javax.swing.JCheckBoxMenuItem createJCheckBoxMenuItem(java.lang.String name, java.lang.String specialization) throws java.util.MissingResourceException, ResourceFormatException, MissingListenerExceptionCreates 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:
java.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.
-
initializeJMenuItem
protected void initializeJMenuItem(javax.swing.JMenuItem item, java.lang.String name, java.lang.String specialization) throws ResourceFormatException, MissingListenerExceptionInitializes 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.
-
-