我有本地化的JavaFX应用程序。但是,由于FXML Loader无法找到本地化软件包,我无法使其正常工作
Caused by: java.util.MissingResourceException: Can't find bundle for base name bundles.lcars, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:845)
at cz.muni.fi.pv168.view.GUI.start(GUI.java:24)
结构:
主要GUI类:
public void start(Stage primaryStage) throws Exception {
Locale locale = Locale.getDefault();
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setResources(ResourceBundle.getBundle("bundles.lcars", locale));
Parent root = FXMLLoader.load(getClass().getResource("lcars.fxml"),ResourceBundle.getBundle("bundles" +
".lcars", locale));
Scene scene = new Scene(root, 1920 , 1080); // 19:10
// set scene to stage and other irrelevant stuff
}
我还尝试将bundle文件夹移动到root包,但没有成功。此外,我尝试了每个已经回答的问题来查询"无法找到基本名称的捆绑包#34;。
编辑@Slaw 我将代码改为此,仍然没有成功
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("lcars.fxml"));
fxmlLoader.setResources(ResourceBundle.getBundle("bundles.lcars", locale));
Parent root = fxmlLoader.load();
感谢您的帮助。