/** * Creates a new {@link FXMLLoader}. <br/> <br/> * Sets: * <ul> * <li>the {@link ClassLoader} to the ClassLoader of the specified type</li> * <li>the {@link ResourceBundle} by looking for a {@code Bundle.properties} file in the package of the specified type (or a locale specific derivation) using the default {@link Locale}</li> * </ul> * @param type the type specifing the {@link ClassLoader} and the package of the {@code Bundle.properties} file * @return a {@link FXMLLoader} */ public static FXMLLoader createFXMLLoader(Class<?> type) { FXMLLoader loader = new FXMLLoader(); loader.setClassLoader(type.getClassLoader()); loader.setResources(Resources.getResourceBundle(type)); return loader; } /**
final String resourcesString = annotation.resources(); if (!resourcesString.isEmpty()) { fxmlLoader.setResources(ResourceBundle.getBundle(resourcesString));
private FXMLLoader createLoader(final Object controller, String fxmlName, ViewConfiguration viewConfiguration) throws FxmlLoadException { Class<?> controllerClass = controller.getClass(); String foundFxmlName = getFxmlName(controllerClass); if (fxmlName != null) { foundFxmlName = fxmlName; } if (foundFxmlName == null) { throw new FxmlLoadException("No FXML File specified!"); } FXMLLoader fxmlLoader = new FXMLLoader( controllerClass.getResource(foundFxmlName)); fxmlLoader.setBuilderFactory(viewConfiguration.getBuilderFactory()); fxmlLoader.setCharset(viewConfiguration.getCharset()); fxmlLoader.setResources(viewConfiguration.getResources()); fxmlLoader.setController(controller); fxmlLoader.setControllerFactory(c -> controller); return fxmlLoader; }
loader.setLocation(url); loader.setClassLoader(classloader); loader.setResources(resourceBundle); if (builderFactory == null) { loader.setBuilderFactory(new JavaFXBuilderFactory(classloader));
private FXMLLoader createLoader(final Object controller, String fxmlName, ViewConfiguration viewConfiguration) throws FxmlLoadException { Class<?> controllerClass = controller.getClass(); String foundFxmlName = getFxmlName(controllerClass); if (fxmlName != null) { foundFxmlName = fxmlName; } if (foundFxmlName == null) { throw new FxmlLoadException("No FXML File specified!"); } FXMLLoader fxmlLoader = new FXMLLoader( controllerClass.getResource(foundFxmlName)); fxmlLoader.setBuilderFactory(viewConfiguration.getBuilderFactory()); fxmlLoader.setCharset(viewConfiguration.getCharset()); fxmlLoader.setResources(viewConfiguration.getResources()); fxmlLoader.setController(controller); fxmlLoader.setControllerFactory(new Callback<Class<?>, Object>() { @Override public Object call(Class<?> arg0) { return controller; } }); return fxmlLoader; }
protected void configureFxmlLoader(@Nonnull FXMLLoader fxmlLoader) { fxmlLoader.setBuilderFactory(new GriffonBuilderFactory(getApplication(), getMvcGroup())); fxmlLoader.setResources(getApplication().getMessageSource().asResourceBundle()); fxmlLoader.setClassLoader(getApplication().getApplicationClassLoader().get()); fxmlLoader.setControllerFactory(klass -> getMvcGroup().getView()); }
loader.setLocation(url); if (resources != null) { loader.setResources(resources);
fxmlLoader.setResources(ResourceBundle.getBundle(bundlePath));