Reputation: 99
I am new to JavaFX.
The application I am trying to create has a header, logout button etc in every stage (and ofcourse some specific content per stage). I do not want to specify these general buttons over and over again in every stage.
I am wondering if there is an option in JavaFX that let's me have a sort of wrapper in FXML (with my header and logout button, etc) where I can load other FXML's (with my specific content) into.
Hope you can help.
Upvotes: 0
Views: 755
Reputation: 45486
First of all, have a look at this. With <fx:include>
you can include FXML files within others. For instance, you could have your header in one FXML, and you could include it in all the scene's FXML files that require that header. You can have a controller for each file, and have separated logic.
You could also create a custom component with your header. Read it here. Your header class, let's say Header.java, will have a FXML file with <fx:root>
.
Then you could include it in any FXML file just with .
For further readings, have a look at the Afterburner.fx framework, or at the DataFX tutorials.
Upvotes: 1