Class JToolBarLoader

java.lang.Object
   |
   +----JToolBarLoader

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


Variable Index

 o ACTION_SUFFIX
Suffix applied to the key used in resource file lookups for an action.
 o commands
 o defaultAction
 o IMAGE_SUFFIX
Suffix applied to the key used in resource file lookups for an image.
 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 STRUT_SIZE
The distance between separated toolbar components.
 o TOOLTIP_SUFFIX
Suffix applied to the key used in resource file lookups for a tooltip.

Constructor Index

 o JToolBarLoader(ResourceBundle)
Create a new JToolBarLoader object.

Method Index

 o createTool(String)
Hook through which every toolbar item is created.
 o createToolBar(String)
Create the toolbar for the specified key.
 o createToolBarButton(String)
Create a button to go inside of the toolbar.
 o filterMnemonic(String, char[])
Filters the mnemonic identifiers out of a label string.
 o getAction(String)
Return the Action with name cmd stored in the command hashtable.
 o getCommands()
Returns a hashtable containing the toolbar commands.
 o getDefaultActionListener()
Return the default action listener.
 o getResource(String)
Read the name of an image from the resource bundle and convert if to an URL.
 o getResourceString(String)
Read a string from the resource file containing the toolbar definition.
 o loadImageIcon(URL)
Hook through which ImageIcons are loaded.
 o reportError(String)
This method will be called, if some errors occur.
 o setCommands(Hashtable)
Set the hashtable containing the toolbar commands.
 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 IMAGE_SUFFIX
 public static final String IMAGE_SUFFIX
Suffix applied to the key used in resource file lookups for an image.

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

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

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

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

 o STRUT_SIZE
 public static final int STRUT_SIZE
The distance between separated toolbar components.

 o resources
 private ResourceBundle resources
 o commands
 private Hashtable commands
 o defaultAction
 private ActionListener defaultAction

Constructors

 o JToolBarLoader
 JToolBarLoader(ResourceBundle resources)
Create a new JToolBarLoader object.

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

Methods

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

 o getCommands
 public Hashtable getCommands()
Returns a hashtable containing the toolbar commands. The hashtable contains pairs of action name and Action object.

 o setCommands
 public void setCommands(Hashtable commands)
Set the hashtable containing the toolbar commands. This hashtable should contain pairs of action name and Action object. If a commands hashtable is set, this should be done before the first call to createToolBar, createTool or createMenuItem.

See Also:
createToolBar, createTool, createToolBarButton
 o getDefaultActionListener
 public ActionListener getDefaultActionListener()
Return the default action listener. This action listener is registered at every toolbar item, which has no associated command in the commands hashtable.

 o setDefaultActionListener
 public void setDefaultActionListener(ActionListener al)
Set the default action listener. This action listener is registered at every toolbar item,which has no associated command in the commands hashtable. If a ActionListener is set, this should be done before the first call to createToolBar, createTool or createMenuToolBarButton.

See Also:
createToolBar, createTool, createToolBarButton
 o createToolBarButton
 protected JButton createToolBarButton(String key)
Create a button to go inside of the toolbar. By default this will load an image resource.

Parameters:
key - The key in the resource file to serve as the basis of lookups.
 o getAction
 protected ActionListener getAction(String cmd)
Return the Action with name cmd stored in the command hashtable. If it doesn't exist, return the default action listener.

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

 o getResource
 protected URL getResource(String key)
Read the name of an image from the resource bundle and convert if to an URL. The name in the resource bundle must be a relative path. It's relative to the location of this class.

 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 createToolBar
 protected JToolBar createToolBar(String key)
Create the toolbar for the specified key. This pulls the definition of the toolbar from the associated resource bundle.

 o createTool
 protected Component createTool(String key)
Hook through which every toolbar item is created. This method can be used to integrate custom gui elements into the toolbar.

 o loadImageIcon
 protected ImageIcon loadImageIcon(URL url)
Hook through which ImageIcons are loaded. If some kind of image cache should be implemented, this method can be overwritten.

 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.