I'm using JavaFX version 15.0.1. I want to make more complex scene via injecting several FXML files into it, like this:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?>
<AnchorPane fx:controller="MainFxmlController">
<children>
<VBox>
<children>
<fx:include fx:id="topMenu" source="top_menu.fxml" />
<fx:include fx:id="navigation" source="navigation.fxml" />
<fx:include fx:id="statusBar" source="status_bar.fxml" />
</children>
</VBox>
</children>
</AnchorPane>
Here I had found that controller of included FXML is loaded automatically and injected into @FXML annotated field named <value of fx:id>Controller in the main controller (in this case MainFxmlController
).
My question is: How can I in this case use my own controller factory to instantiate the corresponding controller class? I need to give controller some dependencies in a constructor.