Java Reference
In-Depth Information
# These are for MessageFormatDemo
#
filedialogs.cantopen.formta=A {0,time} sobre {0,date}, no pude abrir la fila {1}.
Then
MessageFormatDemo
still needs to have a
ResourceBundle
and get the format string
from the bundle. Here is
MessageFormatDemoIntl
:
public
public class
class
MessageFormatDemoIntl
MessageFormatDemoIntl
{
private
private static
static
Date date
=
new
new
Date
();
private
private static
static
String fileName
=
"myfile.txt"
;
public
public static
void
main
(
String
[]
args
) {
ResourceBundle rb
=
ResourceBundle
.
getBundle
(
"Widgets"
);
String format
=
rb
.
getString
(
"filedialogs.cantopen.format"
);
String result
=
MessageFormat
.
format
(
format
,
date
,
fileName
);
System
.
out
.
println
(
result
);
static
void
}
}
Running it might produce the following output in the default locale:
$
java i18n.MessageFormatDemoIntl
At 9:10:13 PM on 23-Feb-2014, myfile.txt could not be opened.
$
MessageFormat
is more complex than this; see the javadoc page for more details and ex-
amples.
Program: MenuIntl
MenuIntl
(shown in
Example 15-1
) is a complete version of the menu code presented in
Example 15-1. MenuIntl.java
public
public class
class
MenuIntl
MenuIntl
extends
extends
JFrame
{
/** "main program" method - construct and show */
public
public static
static
void
void
main
(
String
[]
av
) {