I have a BorderPane (associated with MainController), FXML for BorderPane uses <fx:include> to include the label (with the StatusBarController) in the bottom area of ββthe BorderPane. Unfortunately, the StatusBarController is not injected into an instance of the MainController class, and I do not understand why.
main.fxml: BorderPane with the status bar turned on
<fx:root type="javafx.scene.layout.BorderPane" fx:id="borderPane" xmlns:fx="http://javafx.com/fxml" fx:controller="com.example.controllers.MainController"> <bottom> <fx:include source="statusbar.fxml" /> </bottom> </fx:root>
statusbar.fxml: label and associated controller
<Label fx:id="statusbar" text="A label simulating a status bar" xmlns:fx="http://javafx.com/fxml" fx:controller="com.example.controllers.StatusBarController" />
MainController with the StatusBarController field:
public class MainController { @FXML private StatusBarController statusbarController;
And the beginning of the application:
public void start(Stage primaryStage) { Parent root = null; try { root = FXMLLoader.load(getClass().getResource("/resources/main.fxml")); } catch (IOException e) {
The full source code for my example is available at http://codestefan.googlecode.com/svn/trunk/SubcontrollerAccess/
So the question is: why is the StatusBarController not being entered into the statusbarController MainController variable?
Thanks for any hint!
javafx-2 controller code-injection fxml
stefan.at.wpf
source share