|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface I18n
Interface for Internationalization support in Openamp. The I18n implementation will define where the resources for the given class are stored.
Intended Usage:
There are several possible uses of this interface, outlined below:
I18n i18n = Environment.getI18n();
String message = i18n.get(this, "message", "Please enter a number: ");
There is also similar version of get(...)
that takes
a Class
instead, and thefore can be used in static
contexts. If the Strings you are looking for pertain to specific
types (i.e. uses) you can you the form of get(...)
that specifies this, as the following example illustrates:
I18n i18n = Environment.getI18n();
JButton okButton = new JButton(i18n.get(this, "okButton", i18n.TEXT, "Ok"));
okButton.setTooltipText(i18n.get(this, "okButton", i18n.TOOLTOP, "Ok"));
Again there is a similar version of this method that takes a
Class
instead of an object so it can be used in
static contexts.
Note that in both examples given, the field
parameter to the get(...)
methods are the name of
the variable that holds the string returned. For the these methods,
this is a convention rather than a requirement. However, it
suggested that you maintain this convention because doing so makes
it clearer what is going on and because it is most similar to how
the calls are made in the reflective case below.
Note also that there are several additional get(...)
methods that can be used to make getting paramaterized (as if by
MessageFormat
) Strings easier.
set(...)
methods of this class can help you. Here is
an example:
I18n i18n = Environment.getI18n();
JButton myButton = new JButton();
I18n.set(this, "myButton", myButton);
This will get the string information (both tool tip and text) from the appropriate ResourceBundle and set the button's slots with it.
Note that in this example the field
parameter to the
set(...)
method is the name of the field that holds
the object being setup. For these methods this is a convention
rather than a requirement. However, it suggested that you maintain
this convention because doing so makes it clearer what is going on
and because it is most similar to how the calls are made in the
reflective case below.
public class MyClass {
JButton myButton = new JButton();
public MyClass() {
Environment.getI18n().set(this, "myButton");
}
}
This code will setup the properties of the object held by the
myButton
variable, without the programmer having to
do much at all. Here is an example of the other reflective method:
public class MyClass {
JButton myButton = new JButton();
JLabel myLabel = new JLabel();
public MyClass() {
Environment.getI18n().fill(this);
}
}
Here we can see that a single call is filling in all of the text
for all of the relevant objects, in this case both
myButton
and myLabel
.
In case you were wondering, the oft used I18n abbreviation comes from the 18 characters between the 'I' and the 'n' in the word Internationalization.
Environment
,
BasicI18n
Field Summary | |
---|---|
static int |
MNEMONIC
Mnemonic for a given field. |
static int |
TEXT
Primary type for a given field (default if types aren't applicable). |
static int |
TITLE
Title for components where that is appropriate. |
static int |
TOOLTIP
Tooltip for a given field. |
Method Summary | |
---|---|
void |
fill(java.lang.Object requestor)
Fill in all of the fields of the given object that are of known types (see the set(...) methods of this class) with values obtained from the appropriate ResourceBundle. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
int type,
java.lang.String defaultString)
Get the string associated with the given class/field/type. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object param1)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object[] params)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object param1,
java.lang.Object param2)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
java.lang.String defaultString)
Get the string associated with the given class/field (Defaults to TEXT for the type). |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object param1)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object[] params)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Class requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object param1,
java.lang.Object param2)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
int type,
java.lang.String defaultString)
Get the string associated with the given object/field/type. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object param1)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object[] params)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
int type,
java.lang.String defaultString,
java.lang.Object param1,
java.lang.Object param2)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString)
Get the string associated with the given object/field (Defaults to TEXT for the type). |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object param1)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object[] params)
Method to get a parameterized String, as if by MessageFormat. |
java.lang.String |
get(java.lang.Object requestor,
java.lang.String field,
java.lang.String defaultString,
java.lang.Object param1,
java.lang.Object param2)
Method to get a parameterized String, as if by MessageFormat. |
void |
set(java.lang.Object requestor,
java.lang.String field)
Set the textual properties on a Swing component that is a member of a given class, from values in the ResourceBundle associated with that class. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JButton comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JComponent comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JDialog comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JFrame comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JLabel comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JMenu comp)
Set the textual properties from values in the appropriate ResourceBundle. |
void |
set(java.lang.Object requestor,
java.lang.String field,
javax.swing.JMenuItem comp)
Set the textual properties from values in the appropriate ResourceBundle. |
Field Detail |
---|
static final int TEXT
static final int TITLE
static final int TOOLTIP
static final int MNEMONIC
Method Detail |
---|
java.lang.String get(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString)
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the String or the Swing object that
uses the String (like a button or a label).defaultString
- what to use if the resource can't be found.java.lang.String get(java.lang.Object requestor, java.lang.String field, int type, java.lang.String defaultString)
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the Swing object that uses the String
(like a button or a label).type
- which specific slot in the Swing object the string
pertains to. One of TEXT, TOOLTIP or MNEMONIC.defaultString
- what to use if the resource can't be found.java.lang.String get(java.lang.Class requestor, java.lang.String field, java.lang.String defaultString)
requestor
- the class of the object containing the code
requesting the String (typically Foo.class
field
- the field the String belongs to. Typically this will
be the variable name referring to the String or the Swing object that
uses the String (like a button or a label).defaultString
- what to use if the resource can't be found.java.lang.String get(java.lang.Class requestor, java.lang.String field, int type, java.lang.String defaultString)
requestor
- the classof the object containing the code
requesting the String (typically Foo.class
field
- the field the String belongs to. Typically this will
be the variable name referring to the Swing object that uses the String
(like a button or a label).type
- which specific slot in the Swing object the string
pertains to. One of TEXT, TOOLTIP or MNEMONIC.defaultString
- what to use if the resource can't be found.java.lang.String get(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object param1)
MessageFormat
java.lang.String get(java.lang.Object requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object param1)
MessageFormat
java.lang.String get(java.lang.Class requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object param1)
MessageFormat
java.lang.String get(java.lang.Class requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object param1)
MessageFormat
java.lang.String get(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object param1, java.lang.Object param2)
MessageFormat
java.lang.String get(java.lang.Object requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object param1, java.lang.Object param2)
MessageFormat
java.lang.String get(java.lang.Class requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object param1, java.lang.Object param2)
MessageFormat
java.lang.String get(java.lang.Class requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object param1, java.lang.Object param2)
MessageFormat
java.lang.String get(java.lang.Object requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object[] params)
MessageFormat
java.lang.String get(java.lang.Object requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object[] params)
MessageFormat
java.lang.String get(java.lang.Class requestor, java.lang.String field, java.lang.String defaultString, java.lang.Object[] params)
MessageFormat
java.lang.String get(java.lang.Class requestor, java.lang.String field, int type, java.lang.String defaultString, java.lang.Object[] params)
MessageFormat
void set(java.lang.Object requestor, java.lang.String field, javax.swing.JLabel comp)
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.
MissingResourceException
- if the data can't be found.void set(java.lang.Object requestor, java.lang.String field, javax.swing.JButton comp)
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.
MissingResourceException
- if the data can't be found.void set(java.lang.Object requestor, java.lang.String field, javax.swing.JMenu comp)
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.
MissingResourceException
- if the data can't be found.void set(java.lang.Object requestor, java.lang.String field, javax.swing.JMenuItem comp)
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.
MissingResourceException
- if the data can't be found.void set(java.lang.Object requestor, java.lang.String field, javax.swing.JDialog comp)
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.
MissingResourceException
- if the data can't be found.void set(java.lang.Object requestor, java.lang.String field, javax.swing.JFrame comp)
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.
MissingResourceException
- if the data can't be found.void set(java.lang.Object requestor, java.lang.String field, javax.swing.JComponent comp)
Note: This method just looks for a TitledBorder on the component.
requestor
- object containing the code requesting the
String (typically this
field
- the field the String belongs to. Typically this will
be the variable name referring to the comp
parameter.comp
- the component whose properties are being set.
MissingResourceException
- if the data can't be found.void set(java.lang.Object requestor, java.lang.String field)
The setting of the values of this field will be accomplished by calling the appropriate set(...) method on this class.
requestor
- object containing the code requesting the
Component setup (typically this
field
- the variable name of the component being setup.
MissingResourceException
- if the data can't be found.void fill(java.lang.Object requestor)
The setting of the values of this field will be accomplished by calling the appropriate set(...) method on this class.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |