相关疑难解决方法(0)

如何使用ResourceBundle

我想,如图掌握的Java应用程序内这里.我不能.我创建了一个ListResourceBundle类似于声明的类,并尝试检索键.我不断得到一个例外.如果您查看教程,它会说使用.class文件.这不可能是对的,可以吗?

[项目树]

在此输入图像描述

[源代码]

以下是我正在使用的两个类,只是MainWindow_xx_XX.java文件中的一个,因为它们基本相同.首先是ListResourceBundle:

public class MainWindow_en_US extends ListResourceBundle {

    @Override
    protected Object[][] getContents() {
        return contents;
    }
    private Object[][] contents = {
        {"fileLabel", "File"},
        {"newSessionLabel", "New session..."},
        {"openSessionLabel", "Open session..."},
        {"saveLabel", "Save"},
        {"exitLabel", "Exit"},
        {"editLabel", "Edit"},
        {"toolsLabel", "Tools"},
        {"helpLabel", "Help"}
    };
}
Run Code Online (Sandbox Code Playgroud)

现在我用它加载它的方法:

    private static final int DEFAULT_LOCALE = 0;
    private ResourceBundle bundle;
    public static Locale locale;
    public static final Locale[] supportedLocales = {
        new Locale("en", "US"),
        new Locale("es", "ES")
    };

public MainWindow() …
Run Code Online (Sandbox Code Playgroud)

java swing netbeans resourcebundle internationalization

8
推荐指数
1
解决办法
2万
查看次数