@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("AddressApp");
initRootLayout();
showTabOverview();
}
/**
* Initializes the root layout.
*/
public void initRootLayout() {
try {
// Load root layout from fxml file.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("rootLayout.fxml"));
rootLayout = (BorderPane) loader.load();
// Show the scene containing the root layout.
Scene scene = new Scene(rootLayout);
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Shows the Tab overview inside the root layout.
*/
public void showTabOverview() {
try {
// Load person overview.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("tabLayout.fxml"));
TabPane TabOverview = (TabPane) loader.load();
// Set person overview into the center of root layout.
rootLayout.setCenter(TabOverview);
} catch (IOException e) {
e.printStackTrace();
}
}
It does work with my FXML of the tabpane.
<TabPane xmlns:fx="http://www.w3.org/1999/XSL/Transform">
<tabs>
<Tab text="Untitled Tab 1">
</Tab>
<Tab text="Untitled Tab 2">
</Tab>
</tabs>
</TabPane>
But I'm trying to add per tab FXML with this method I found on this link
<Tab text="Untitled Tab 1">
<content>
<fx:include fx:id="fooTabPage" source="fooTabPage.fxml"/>
</content>
</Tab>
When I add the include with the new source for the tab it gives me IllegalArgumentException: Unable to coerce javafx.scene.control.Tab@3885406e to class javafx.scene.Node.
How do I make those tabs actually being a node? is there specific way to create them?