I am trying to migrate Javafx2.2 application to Javafx8. I am getting following issue while using nested FXML
:
javafx.fxml.LoadException: Root hasn't been set.
Use method setRoot() before load.
FXML file:
<fx:root type="javafx.scene.layout.VBox"
xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx/8"
fx:controller="com.ui.TestController">
<TextField fx:id="textField"/>
<Button text="Click Me"/>
</fx:root>
Code:
FXMLLoader loader = new FXMLLoader();
loader.setResources(bundle);
InputStream in = Main.class.getClassLoader().getResourceAsStream(fxml);
loader.setBuilderFactory(new JavaFXBuilderFactory());
loader.setLocation(Main.class.getResource(fxml));
Node page = null;
try {
page = (Node) loader.load(in);
} catch (IOException e) {
logger.error("{}", e);
} finally {
try {
in.close();
} catch (IOException e) {
logger.error("{}", e);
}
}
I need page
node to set in another BorderPane.center
. It works with Javafx2.2. What I am missing here? Any help would be appreciated.