简体   繁体   English

JavaFX8。 是否必须为每个FXMLLoader设置资源束?

[英]JavaFX8. Do I have to set the resource bundle for every FXMLLoader?

I have one large resource file for the whole application, so it would be nice if I could set it only ones for the whole JavaFX scene and not every time I do new FXMLLoader(...) . 我为整个应用程序提供了一个大的资源文件,因此,如果只为整个JavaFX场景设置一个文件,而不是每次执行new FXMLLoader(...)都设置一个文件,那将是很好的。

Is there way to do so? 有办法吗?

As far as I am aware, there is no mechanism to set a default resource bundle. 据我所知,没有任何机制可以设置默认资源包。 You can always create a utility method to do this if you need: 如果需要,您始终可以创建实用程序方法来执行此操作:

public class MyUtils {

    private static final ResourceBundle bundle = ... ;

    public static FXMLLoader getLoader(URL location) {
        return new FXMLLoader(location, bundle);
    }

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM