能获取所有 .property 文件信息吗? 不好意思! 低级错误: property 改为properties 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 YuLimin(阿敏当兵) 兄台: java.util.ResourceBundle 在我不知道有多少时,如何获取所有的国际化信息呀? 看文档不就行了!SimpleI18NTest.html<title>Test</title><applet code="SimpleI18NTest.class" width=200 height=100></applet>SimpleI18NTest.javaimport java.applet.Applet;import java.util.Locale;import java.util.MissingResourceException;import java.util.ResourceBundle;import java.awt.Choice;import java.awt.Label;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;public class SimpleI18NTest extends Applet implements ItemListener{ private Label guiLabel = new Label(); private Choice choice = new Choice(); private Object[] localeCountry = { Locale.ENGLISH, Locale.FRENCH, Locale.CANADA, Locale.CHINA, Locale.CHINESE, Locale.TAIWAN//在JDK1.2.2的AppletViewer打开,当中:中国台湾为...!!!愤怒!!! }; public void init() { for(int i = 0;i < localeCountry.length;i++) { choice.add(((Locale)localeCountry[i]).getDisplayName()); } choice.addItemListener(this); add(choice); add(guiLabel); guiLabel.setLocale(Locale.ENGLISH); internationalize(); } public void itemStateChanged(ItemEvent event) { int index = choice.getSelectedIndex(); guiLabel.setLocale((Locale)localeCountry[index]); /* if(index == 0) { guiLabel.setLocale(Locale.ENGLISH); } else { guiLabel.setLocale(Locale.FRENCH); } */ internationalize(); validate(); } private void internationalize() { String s = getIdentifierString(guiLabel.getLocale()); if(s != null) { guiLabel.setText(s); guiLabel.invalidate(); } } private String getIdentifierString(Locale l) { ResourceBundle bundle = null; try { bundle = ResourceBundle.getBundle("LabelsBundle",l); } catch(MissingResourceException e) { e.printStackTrace(); } if(bundle == null) { return null; } else { return(String)bundle.getObject("Identifier"); } }}建立文件LabelsBundle_en.propertiesLabelsBundle_fr.propertiesLabelsBundle_zh.propertiesLabelsBundle_zh_CN.propertiesLabelsBundle_zh_TW.properties内容# SimpleI8N zh_CN Property BundleIdentifier=GUI zh_CN 中华人民共和国 [求助]确保字符串是1-100的数,怎么写正则? java中拖放数据的时候如何像WINDOWS一样在鼠标下面出现拖放数据的图片 求救,java命令,给分100 请问一下java中要对一个double数进行四舍五入要用那个类呀? 请教 ..... (来者有分) 关于使用ANT几个问题 简单问题,但我不会,急!在线 为了平息"倒分"现将我得分的代码全部公开!是java解析XML然后插入数据库,再读出来生成XML!! 日期的问题,我要的是一个字串就象:“200204160819”,怎么做? 不同jdk版本的兼容问题? 怎么老有这样的错误啊??帮帮忙啊 用Vector初始化JTable的问题!
YuLimin(阿敏当兵) 兄台: java.util.ResourceBundle
在我不知道有多少时,如何获取所有的国际化信息呀?
<applet code="SimpleI18NTest.class" width=200 height=100>
</applet>
SimpleI18NTest.javaimport java.applet.Applet;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;import java.awt.Choice;
import java.awt.Label;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;public class SimpleI18NTest extends Applet implements ItemListener
{
private Label guiLabel = new Label();
private Choice choice = new Choice();
private Object[] localeCountry =
{
Locale.ENGLISH,
Locale.FRENCH,
Locale.CANADA,
Locale.CHINA,
Locale.CHINESE,
Locale.TAIWAN//在JDK1.2.2的AppletViewer打开,当中:中国台湾为...!!!愤怒!!!
}; public void init()
{
for(int i = 0;i < localeCountry.length;i++)
{
choice.add(((Locale)localeCountry[i]).getDisplayName());
} choice.addItemListener(this); add(choice);
add(guiLabel); guiLabel.setLocale(Locale.ENGLISH);
internationalize();
} public void itemStateChanged(ItemEvent event)
{
int index = choice.getSelectedIndex();
guiLabel.setLocale((Locale)localeCountry[index]); /* if(index == 0)
{
guiLabel.setLocale(Locale.ENGLISH);
}
else
{
guiLabel.setLocale(Locale.FRENCH);
}
*/ internationalize();
validate();
} private void internationalize()
{
String s = getIdentifierString(guiLabel.getLocale()); if(s != null)
{
guiLabel.setText(s);
guiLabel.invalidate();
}
} private String getIdentifierString(Locale l)
{
ResourceBundle bundle = null; try
{
bundle = ResourceBundle.getBundle("LabelsBundle",l);
}
catch(MissingResourceException e)
{
e.printStackTrace();
}
if(bundle == null)
{
return null;
}
else
{
return(String)bundle.getObject("Identifier");
}
}
}建立文件
LabelsBundle_en.properties
LabelsBundle_fr.properties
LabelsBundle_zh.properties
LabelsBundle_zh_CN.properties
LabelsBundle_zh_TW.properties内容
# SimpleI8N zh_CN Property BundleIdentifier=GUI zh_CN 中华人民共和国