|
java tuturial 中的国际化程序,我改写后,但是无法显示出中文,
请问能够解决吗?感谢
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class testI18N
{
public static void main(String argv[])
{
String language;
String country;
language = new String("zh");
country = new String("CN");
Locale currentLocale;
ResourceBundle messages;
currentLocale = new Locale(language, country);
System.out.println(currentLocale);
messages =
ResourceBundle.getBundle("MessagesBundle",currentLocale);
JFrame f=new JFrame();
f.setSize(400,300);
JButton b1=new JButton();
b1.setFont(new Font("tlc-song",0,16));
b1.setText(messages.getString("greetings"));
JButton b2=new JButton();
b2.setFont(new Font("tlc-song",0,16));
b2.setText(messages.getString("inquiry"));
JButton b3=new JButton();
b3.setFont(new Font("tlc-song",0,16));
b3.setText(messages.getString("farewell"));
b3.setText("你好!") ;
f.getContentPane().add(b1);
f.getContentPane().add(b2);
f.getContentPane().add(b3);
f.show();
}
}
配备了相应的MessagesBundle_zh_CN.properties文件
greetings = 你好
farewell =你好
inquiry = 你现在还好吗? |
|