/** * 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; } /**
@SuppressWarnings("null") @Override public Node getGraphicNode(URI uri) throws IOException { if( uri.isPlatformPlugin() ) { Bundle b = org.eclipse.core.runtime.Platform.getBundle(uri.segment(1)); if( b != null ) { StringBuilder sb = new StringBuilder(); for (int i = 2; i < uri.segmentCount(); i++) { if (sb.length() != 0) { sb.append("/"); //$NON-NLS-1$ } sb.append(uri.segment(i)); } FXMLLoader loader = new FXMLLoader(); loader.setClassLoader(b.adapt(BundleWiring.class).getClassLoader()); URL url = b.getResource(sb.toString()); loader.setLocation(url); return loader.load(); } else { throw new IOException("Unknown bundle '"+uri.segment(1)+"'"); //$NON-NLS-1$ //$NON-NLS-2$ } } else { return FXMLLoader.load(new URL(uri.toString())); } } }
FXMLLoader loader = new FXMLLoader(); loader.setLocation(url); loader.setClassLoader(classloader); loader.setResources(resourceBundle); if (builderFactory == null) {
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()); }