Java Reference
In-Depth Information
messageType
);
}
/** Just get a String (for dialogs, labels, etc.) */
public
public static
static
String
getString
(
ResourceBundle b
,
String name
,
String dflt
) {
String result
;
try
try
{
result
=
b
.
getString
(
name
);
}
catch
catch
(
MissingResourceException e
) {
result
=
dflt
;
}
return
return
result
;
}
}
Creating a Dialog with I18N Resources
Problem
You want to internationalize a dialog.
Solution
Use a
ResourceBundle
.
Discussion
This is similar to the use of
ResourceBundle
in the previous recipes and shows the code for
public
public class
class
JOptionDemo
JOptionDemo
extends
extends
JFrame
{
private
private static
static final
final
long
long
serialVersionUID
=
1L
;
private
private
ResourceBundle rb
;
// Constructor
JOptionDemo
(
String s
) {
super
super
(
s
);