Class MenuLoader

java.lang.Object
   |
   +----MenuLoader

class MenuLoader
extends Object
Builds up a AWT menu by reading the settings from a resource file. It's intended to use this class for loading menu's created with Magic Menu.


Variable Index

 o ACCEL_SUFFIX
Suffix applied to the key used in resource file lookups for a accelerator.
 o ACTION_SUFFIX
Suffix applied to the key used in resource file lookups for an action.
 o defaultAction
 o eventClass
A reference to the java.awt.event.InputEvent class.
 o keyEventClass
A reference to the java.awt.event.KeyEvent class.
 o LABEL_SUFFIX
Suffix applied to the key used in resource file lookups for a label.
 o MNEMONIC_ESCAPE
The escape character to identify a mnemonic in a label.
 o resources
 o TYPE_CHECKBOX
Type identifier of a checkbox menu item.
 o TYPE_ITEM
Type identifier of a menu item.
 o TYPE_MENU
Type identifier of a submenu.
 o TYPE_SUFFIX
Suffix applied to the key used in resource file lookups for the type of a menu item.

Constructor Index

 o MenuLoader(ResourceBundle)
Create a new JMenuLoader object.

Method Index

 o ()
 o createMenu(String)
Create a menu.
 o createMenuBar(String)
Create the menubar for the specified key.
 o createMenuItem(String)
This is the hook through which all menu items are created.
 o filterMnemonic(String, char[])
Filters the mnemonic identifiers out of a label string.
 o getAction(String)
Return the default action listener.
 o getDefaultActionListener()
Returns the default action listener.
 o getResourceString(String)
Read a string from the resource bundle containing the menu definition.
 o reportError(String)
This method will be called, if some errors occur.
 o setDefaultActionListener(ActionListener)
Set the default action listener.
 o tokenize(String)
Take the given string and chop it up into a series of strings on whitespace boundries.

Variables

 o LABEL_SUFFIX
 public static final String LABEL_SUFFIX
Suffix applied to the key used in resource file lookups for a label.

 o ACCEL_SUFFIX
 public static final String ACCEL_SUFFIX
Suffix applied to the key used in resource file lookups for a accelerator.

 o ACTION_SUFFIX
 public static final String ACTION_SUFFIX
Suffix applied to the key used in resource file lookups for an action.

 o TYPE_SUFFIX
 public static final String TYPE_SUFFIX
Suffix applied to the key used in resource file lookups for the type of a menu item.

 o TYPE_ITEM
 public static final String TYPE_ITEM
Type identifier of a menu item.

 o TYPE_MENU
 public static final String TYPE_MENU
Type identifier of a submenu.

 o TYPE_CHECKBOX
 public static final String TYPE_CHECKBOX
Type identifier of a checkbox menu item.

 o MNEMONIC_ESCAPE
 public static final char MNEMONIC_ESCAPE
The escape character to identify a mnemonic in a label.

 o eventClass
 private static Class eventClass
A reference to the java.awt.event.InputEvent class.

 o keyEventClass
 private static Class keyEventClass
A reference to the java.awt.event.KeyEvent class.

 o resources
 private ResourceBundle resources
 o defaultAction
 private ActionListener defaultAction

Constructors

 o MenuLoader
 MenuLoader(ResourceBundle resources)
Create a new JMenuLoader object.

Parameters:
resources - A resources bundle containing the menu settings.

Methods

 o
 static void ()
 o filterMnemonic
 private static String filterMnemonic(String label,
                                      char ch[])
Filters the mnemonic identifiers out of a label string.

 o getDefaultActionListener
 public ActionListener getDefaultActionListener()
Returns the default action listener. This ActionListener is registered at every menu item.

 o setDefaultActionListener
 public void setDefaultActionListener(ActionListener al)
Set the default action listener. This action listener is registered at every menu item. If a ActionListener is set, this should be done before the first call to createMenuBar, createMenu or createMenuItem.

See Also:
createMenuBar, createMenu, createMenuItem
 o createMenuItem
 public MenuItem createMenuItem(String key)
This is the hook through which all menu items are created. CheckbBoxMenuItems are connected by a special adapter class, which ensures compatibility to the ActionListener interface.

 o getAction
 protected ActionListener getAction(String cmd)
Return the default action listener. This Method should be overwritten, if not all menu items should register the same action listener.

Parameters:
cmd - The action command of the associated menu item.
 o getResourceString
 protected String getResourceString(String key)
Read a string from the resource bundle containing the menu definition.

 o tokenize
 protected String[] tokenize(String input)
Take the given string and chop it up into a series of strings on whitespace boundries. This is useful for trying to get an array of strings out of the resource file.

 o createMenuBar
 protected MenuBar createMenuBar(String key)
Create the menubar for the specified key. This pulls the definition of the menu from the associated resource file.

 o createMenu
 protected Menu createMenu(String key)
Create a menu. This pulls the definition of the menu from the associated resource file.

 o reportError
 protected void reportError(String text)
This method will be called, if some errors occur. By default this will cause an output to stderr.