我有这个MainView.fxml文件:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.VBox?>
<VBox prefHeight="600.0" prefWidth="900.0"xmlns="http://javafx.com/javafx/8.0.171"xmlns:fx="http://javafx.com/fxml/1">
<children>
<fx:include source="./components/header/MainMenu.fxml" />
<fx:include source="./BodyContent.fxml" />
<fx:include source="./components/footer/StatusBar.fxml" />
</children>
</VBox>
BodyContent.fxml的内容:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.geometry.Insets?>
<VBox>
<children>
<fx:include source="./project-category-picker-
pane/ProjectCategoryPickerPane.fxml" />
</children>
</VBox>
ProjectCategoryPickerPane.fxml的内容:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.geometry.Insets?>
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0">
<children>
<ChoiceBox prefWidth="450.0" />
<ChoiceBox disable="true" prefWidth="450.0" />
<ChoiceBox disable="true" layoutX="13.0" layoutY="13.0"
prefWidth="450.0" />
</children>
<padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
</HBox>
执行上述操作时,MainView.fxml控制器在加载器上的加载方法返回null,但是当我将ProjectCategoryPickerPanePane.fxml的内容直接注入BodyContent.fxml时,该加载方法可以正常工作
MainView控制器类中是否应该做一些事情以支持嵌套的<fx:include />
?