Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.batik.util.gui.resource
Class MenuFactory  view MenuFactory download MenuFactory.java

java.lang.Object
  extended byorg.apache.batik.util.gui.resource.ResourceManager
      extended byorg.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: mod+mod+...+X
   where mod is Shift, Meta, Alt or Ctrl
 '-' represents a separator
 
All entries are optional except the '.type' entry Consecutive RADIO items are put in a ButtonGroup

Version:
$Id: MenuFactory.java,v 1.8 2005/03/27 08:58:37 cam Exp $

Field Summary
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
           
 
Fields inherited from class org.apache.batik.util.gui.resource.ResourceManager
bundle
 
Constructor Summary
MenuFactory(java.util.ResourceBundle rb, ActionMap am)
          Creates a new menu factory
 
Method Summary
 javax.swing.JCheckBoxMenuItem createJCheckBoxMenuItem(java.lang.String name)
          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.JMenuBar createJMenuBar(java.lang.String name)
          Creates and returns a swing menu bar
protected  javax.swing.JComponent createJMenuComponent(java.lang.String name)
          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.JRadioButtonMenuItem createJRadioButtonMenuItem(java.lang.String name)
          Creates and returns a new swing radio button menu item
protected  void initializeJMenuItem(javax.swing.JMenuItem item, java.lang.String name)
          Initializes a swing menu item
protected  javax.swing.KeyStroke toKeyStroke(java.lang.String str)
          Translate a string into a key stroke.
 
Methods inherited from class org.apache.batik.util.gui.resource.ResourceManager
getBoolean, getCharacter, getInteger, getString, getStringList, getStringList, getStringList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

Method Detail

createJMenuBar

public javax.swing.JMenuBar createJMenuBar(java.lang.String name)
                                    throws java.util.MissingResourceException,
                                           ResourceFormatException,
                                           MissingListenerException
Creates and returns a swing menu bar


createJMenuComponent

protected javax.swing.JComponent createJMenuComponent(java.lang.String name)
                                               throws java.util.MissingResourceException,
                                                      ResourceFormatException,
                                                      MissingListenerException
Creates and returns a menu item or a separator


createJMenu

public javax.swing.JMenu createJMenu(java.lang.String name)
                              throws java.util.MissingResourceException,
                                     ResourceFormatException,
                                     MissingListenerException
Creates and returns a new swing menu


createJMenuItem

public javax.swing.JMenuItem createJMenuItem(java.lang.String name)
                                      throws java.util.MissingResourceException,
                                             ResourceFormatException,
                                             MissingListenerException
Creates and returns a new swing menu item


createJRadioButtonMenuItem

public javax.swing.JRadioButtonMenuItem createJRadioButtonMenuItem(java.lang.String name)
                                                            throws java.util.MissingResourceException,
                                                                   ResourceFormatException,
                                                                   MissingListenerException
Creates and returns a new swing radio button menu item


createJCheckBoxMenuItem

public javax.swing.JCheckBoxMenuItem createJCheckBoxMenuItem(java.lang.String name)
                                                      throws java.util.MissingResourceException,
                                                             ResourceFormatException,
                                                             MissingListenerException
Creates and returns a new swing check box menu item


initializeJMenuItem

protected void initializeJMenuItem(javax.swing.JMenuItem item,
                                   java.lang.String name)
                            throws ResourceFormatException,
                                   MissingListenerException
Initializes a swing menu item


toKeyStroke

protected javax.swing.KeyStroke toKeyStroke(java.lang.String str)
Translate a string into a key stroke. See the class comment for details