可以使用下面的代码在 Java 类中设置 ResourceBundle
。
FXMLLoader loader = new FXMLLoader(getClass().getResource("my_view.fxml"));
loader.setResources(MyRes.getBundle());
//Node myNode = (Node) loader.load();
是否可以在 FXML 文件本身中指定 ResourceBundle?
最佳答案
<fx:include>
also supports attributes for specifying the name of the resource bundle that should be used to localize the included content, as well as the character set used to encode the source file.<fx:include source="filename" resources="resource_file" charset="utf-8"/>
不确定它不是包含文件的情况,因为我没有看到相关文档(通过一些快速测试,我认为这是不可能的,尽管我可能是错的)。
关于javafx - 在 JavaFX 的 FXML 文件中指定 ResourceBundle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46103533/