JHotDraw 7.1

org.jhotdraw.util
Class ResourceBundleUtil

java.lang.Object
  extended by org.jhotdraw.util.ResourceBundleUtil

public class ResourceBundleUtil
extends java.lang.Object

This is a convenience wrapper for accessing resources stored in a ResourceBundle.

Version:
1.7.1 2006-12-11 Method configureToolBarButton sets the text of the button when no image is provided.
1.7 2006-05-06 Suffixes changed. Redirection via LocaleUtil added.
1.6.1 2006-04-12 Method getBundle() added.
1.6 2006-03-15 Method setBaseClass/getBaseClass added.
1.5 2006-02-15 Methods getInteger, getLAFBundle, configureButton and getTip() added.
1.4 2005-01-04 Methods configureAction and configureMenu added.
1.3 2001-10-10 The default resource name changed from 'name_Metal' to 'name'.
1.2 2001-07-23 Adaptation to JDK 1.3 in progress.
1.0 2000-06-10 Created.
Author:
Werner Randelshofer, Staldenmattweg 2, CH-6405 Immensee, Switzerland

Constructor Summary
ResourceBundleUtil(java.util.ResourceBundle r)
          Creates a new ResouceBundleUtil which wraps the provided resource bundle.
 
Method Summary
 void configureAction(javax.swing.Action action, java.lang.String argument)
           
 void configureAction(javax.swing.Action action, java.lang.String argument, java.lang.Class baseClass)
           
 void configureButton(javax.swing.AbstractButton button, java.lang.String argument)
           
 void configureButton(javax.swing.AbstractButton button, java.lang.String argument, java.lang.Class baseClass)
           
 void configureMenu(javax.swing.JMenuItem menu, java.lang.String argument)
           
 void configureToolBarButton(javax.swing.AbstractButton button, java.lang.String argument)
           
 void configureToolBarButton(javax.swing.AbstractButton button, java.lang.String argument, java.lang.Class baseClass)
           
 javax.swing.JMenuItem createMenuItem(javax.swing.Action a, java.lang.String baseName)
           
 javax.swing.KeyStroke getAcc(java.lang.String key)
          Get a KeyStroke from the ResourceBundle.
 java.lang.Class getBaseClass()
           
 java.util.ResourceBundle getBundle()
           
 java.lang.String getFormatted(java.lang.String key, java.lang.Object... arguments)
          Gets a resource string formatted with MessageFormat.
 java.lang.String getFormatted(java.lang.String key, java.lang.String argument)
          Gets a resource string formatted with MessageFormat.
 javax.swing.ImageIcon getImageIcon(java.lang.String key, java.lang.Class baseClass)
          Get an image icon from the ResourceBundle.
 java.lang.Integer getInteger(java.lang.String key)
          Get an Integer from the ResourceBundle.
 javax.swing.KeyStroke getKeyStroke(java.lang.String key)
          Get a KeyStroke from the ResourceBundle.
static ResourceBundleUtil getLAFBundle(java.lang.String baseName)
          Get the appropriate ResourceBundle subclass.
static ResourceBundleUtil getLAFBundle(java.lang.String baseName, java.util.Locale locale)
          Get the appropriate ResourceBundle subclass.
 char getMnem(java.lang.String key)
          Get a Mnemonic from the ResourceBundle.
 char getMnemonic(java.lang.String key)
          Get a Mnemonic from the ResourceBundle.
 java.lang.String getString(java.lang.String key)
          Get a String from the ResourceBundle.
 java.lang.String getTip(java.lang.String key)
          Get a Mnemonic from the ResourceBundle.
 void setBaseClass(java.lang.Class baseClass)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceBundleUtil

public ResourceBundleUtil(java.util.ResourceBundle r)
Creates a new ResouceBundleUtil which wraps the provided resource bundle.

Method Detail

getBundle

public java.util.ResourceBundle getBundle()

getString

public java.lang.String getString(java.lang.String key)
Get a String from the ResourceBundle.
Convenience method to save casting.

Parameters:
key - The key of the property.
Returns:
The value of the property. Returns the key if the property is missing.

getInteger

public java.lang.Integer getInteger(java.lang.String key)
Get an Integer from the ResourceBundle.
Convenience method to save casting.

Parameters:
key - The key of the property.
Returns:
The value of the property. Returns -1 if the property is missing.

getImageIcon

public javax.swing.ImageIcon getImageIcon(java.lang.String key,
                                          java.lang.Class baseClass)
Get an image icon from the ResourceBundle.
Convenience method .

Parameters:
key - The key of the property. This method appends ".icon" to the key.
Returns:
The value of the property. Returns null if the property is missing.

getMnemonic

public char getMnemonic(java.lang.String key)
Get a Mnemonic from the ResourceBundle.
Convenience method.

Parameters:
key - The key of the property.
Returns:
The first char of the value of the property. Returns '\0' if the property is missing.

getMnem

public char getMnem(java.lang.String key)
Get a Mnemonic from the ResourceBundle.
Convenience method.

Parameters:
key - The key of the property. This method appends ".mnem" to the key.
Returns:
The first char of the value of the property. Returns '\0' if the property is missing.

getTip

public java.lang.String getTip(java.lang.String key)
Get a Mnemonic from the ResourceBundle.
Convenience method.

Parameters:
key - The key of the property. This method appends ".tip" to the key.
Returns:
The ToolTip. Returns null if no tooltip is defined.

getKeyStroke

public javax.swing.KeyStroke getKeyStroke(java.lang.String key)
Get a KeyStroke from the ResourceBundle.
Convenience method.

Parameters:
key - The key of the property.
Returns:
javax.swing.KeyStroke.getKeyStroke(value). Returns null if the property is missing.

getAcc

public javax.swing.KeyStroke getAcc(java.lang.String key)
Get a KeyStroke from the ResourceBundle.
Convenience method.

Parameters:
key - The key of the property. This method adds ".acc" to the key.
Returns:
javax.swing.KeyStroke.getKeyStroke(value). Returns null if the property is missing.

getFormatted

public java.lang.String getFormatted(java.lang.String key,
                                     java.lang.String argument)
Gets a resource string formatted with MessageFormat.

Parameters:
key -
argument -
Returns:
Formatted stirng.

getFormatted

public java.lang.String getFormatted(java.lang.String key,
                                     java.lang.Object... arguments)
Gets a resource string formatted with MessageFormat.

Parameters:
key -
arguments -
Returns:
Formatted stirng.

getLAFBundle

public static ResourceBundleUtil getLAFBundle(java.lang.String baseName)
                                       throws java.util.MissingResourceException
Get the appropriate ResourceBundle subclass. The baseName is extended by the Swing Look and Feel ID and by the Locale code. The default Look and Feel ID is Metal.

Throws:
java.util.MissingResourceException
See Also:
ResourceBundle

setBaseClass

public void setBaseClass(java.lang.Class baseClass)

getBaseClass

public java.lang.Class getBaseClass()

configureAction

public void configureAction(javax.swing.Action action,
                            java.lang.String argument)

configureAction

public void configureAction(javax.swing.Action action,
                            java.lang.String argument,
                            java.lang.Class baseClass)

configureButton

public void configureButton(javax.swing.AbstractButton button,
                            java.lang.String argument)

configureButton

public void configureButton(javax.swing.AbstractButton button,
                            java.lang.String argument,
                            java.lang.Class baseClass)

configureToolBarButton

public void configureToolBarButton(javax.swing.AbstractButton button,
                                   java.lang.String argument)

configureToolBarButton

public void configureToolBarButton(javax.swing.AbstractButton button,
                                   java.lang.String argument,
                                   java.lang.Class baseClass)

configureMenu

public void configureMenu(javax.swing.JMenuItem menu,
                          java.lang.String argument)

createMenuItem

public javax.swing.JMenuItem createMenuItem(javax.swing.Action a,
                                            java.lang.String baseName)

getLAFBundle

public static ResourceBundleUtil getLAFBundle(java.lang.String baseName,
                                              java.util.Locale locale)
                                       throws java.util.MissingResourceException
Get the appropriate ResourceBundle subclass. The ID of the current Look and Feel is prepended to the locale attributes.

Throws:
java.util.MissingResourceException
See Also:
ResourceBundle

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.