|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jfree.util.ResourceBundleSupport
An utility class to ease up using property-file resource bundles.
The class support references within the resource bundle set to minimize the occurence of duplicate keys. References are given in the format:a.key.name=@referenced.keyA lookup to a key in an other resource bundle should be written by
a.key.name=@@resourcebundle_name@referenced.key
| Constructor Summary | |
protected |
ResourceBundleSupport(java.lang.String resourceBase)
Creates a new instance. |
| Method Summary | |
javax.swing.JMenu |
createMenu(java.lang.String keyPrefix)
Returns a JMenu created from a resource bundle definition. |
javax.swing.Icon |
createTransparentIcon(int width,
int height)
Creates a transparent icon. |
java.lang.String |
formatMessage(java.lang.String key,
java.lang.Object parameter)
Formats the message stored in the resource bundle (using a MessageFormat). |
java.lang.String |
formatMessage(java.lang.String key,
java.lang.Object[] parameters)
Formats the message stored in the resource bundle (using a MessageFormat). |
java.lang.String |
formatMessage(java.lang.String key,
java.lang.Object par1,
java.lang.Object par2)
Formats the message stored in the resource bundle (using a MessageFormat). |
javax.swing.Icon |
getIcon(java.lang.String key)
Returns an unscaled icon. |
javax.swing.Icon |
getIcon(java.lang.String key,
boolean large)
Returns an scaled icon suitable for buttons or menus. |
javax.swing.KeyStroke |
getKeyStroke(java.lang.String key)
Returns the keystroke stored at the given resourcebundle key. |
java.lang.Integer |
getMnemonic(java.lang.String key)
Returns the mnemonic stored at the given resourcebundle key. |
protected java.lang.String |
getResourceBase()
The base name of the resource bundle. |
java.net.URL |
getResourceURL(java.lang.String key)
Returns a URL pointing to a resource located in the classpath. |
java.lang.String |
getString(java.lang.String key)
Gets a string for the given key from this resource bundle or one of its parents. |
protected java.lang.String |
internalGetString(java.lang.String key)
Performs the lookup for the given key. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected ResourceBundleSupport(java.lang.String resourceBase)
| Method Detail |
protected final java.lang.String getResourceBase()
public java.lang.String getString(java.lang.String key)
key - the key for the desired string
java.lang.NullPointerException - if key is null
java.util.MissingResourceException - if no object for the given key can be found
java.lang.ClassCastException - if the object found for the given key is not a stringprotected java.lang.String internalGetString(java.lang.String key)
key - the key for the string
public javax.swing.Icon getIcon(java.lang.String key,
boolean large)
key - the name of the resource bundle keylarge - true, if the image should be scaled to 24x24, or false for 16x16
public javax.swing.Icon getIcon(java.lang.String key)
key - the name of the resource bundle key
public java.lang.Integer getMnemonic(java.lang.String key)
For the enter key, the resource bundle would therefore either contain "ENTER" or "\n".
a.resourcebundle.key=ENTER an.other.resourcebundle.key=\n
key - the resourcebundle key
public javax.swing.KeyStroke getKeyStroke(java.lang.String key)
The keystroke will be composed of a simple key press and the plattform's MenuKeyMask.
The keystrokes character key should be either the symbolic name of one of the KeyEvent.VK_* constants (without the 'VK_') or the character for that key.
For the enter key, the resource bundle would therefore either contain "ENTER" or "\n".
a.resourcebundle.key=ENTER an.other.resourcebundle.key=\n
key - the resourcebundle key
Toolkit.getMenuShortcutKeyMask()public javax.swing.JMenu createMenu(java.lang.String keyPrefix)
The menu definition consists of two keys, the name of the menu and the mnemonic for that menu. Both keys share a common prefix, which is extended by ".name" for the name of the menu and ".mnemonic" for the mnemonic.
# define the file menu menu.file.name=File menu.file.mnemonic=FThe menu definition above can be used to create the menu by calling
createMenu ("menu.file").
keyPrefix - the common prefix for that menu
public java.net.URL getResourceURL(java.lang.String key)
Example: The load a file named 'logo.gif' which is stored in a java package named 'org.jfree.resources':
mainmenu.logo=org/jfree/resources/logo.gifThe URL for that file can be queried with:
getResource("mainmenu.logo");.
key - the key for the resource
public javax.swing.Icon createTransparentIcon(int width,
int height)
width - the width of the new iconheight - the height of the new icon
public java.lang.String formatMessage(java.lang.String key,
java.lang.Object parameter)
key - the resourcebundle keyparameter - the parameter for the message
public java.lang.String formatMessage(java.lang.String key,
java.lang.Object par1,
java.lang.Object par2)
key - the resourcebundle keypar1 - the first parameter for the messagepar2 - the second parameter for the message
public java.lang.String formatMessage(java.lang.String key,
java.lang.Object[] parameters)
key - the resourcebundle keyparameters - the parameter collection for the message
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||