public WorldPane() { log.finest("constructing world pane"); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("WorldPane.fxml")); fxmlLoader.setRoot(this); fxmlLoader.setController(this); try { fxmlLoader.load(); } catch (IOException exception) { throw new RuntimeException(exception); } }
public FailurePane() { getStyleClass().add("failure"); setMinWidth(220.0d); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FailurePane.fxml")); fxmlLoader.setRoot(this); fxmlLoader.setController(this); try { fxmlLoader.load(); } catch (IOException exception) { throw new RuntimeException(exception); } }
fxmlLoader.setRoot(instance);
/** * Loads the <class name>.fxml file, which is expected to be in the same package as the specified type. * <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> * * The root element of the FXML document is expected to be: * <br/> <br/> * {@code <fx:root type="{super-type}" xmlns:fx="http://javafx.com/fxml">} * <br/> <br/> * where "super-type" is the super type of the specified type. * @param type the type * @param rootController the Object acting as the root and as the controller. * @throws IOException */ public static void loadRoot(Class<?> type, final Object rootController) throws IOException { FXMLLoader loader = createFXMLLoader(type); loader.setRoot(rootController); loader.setController(rootController); load(loader, type); }