I've started a new JavaFX 2 project and I've built the main Stage with SceneBuilder. How can I design a new, separate Pane (i.e. a new FXML file with its own controller class) and add it to the main scene?
问问题
102 次
1 回答
1
Static Inclusion
fx:include
can be placed in the parent FXML file to statically include a child FXML with it's own Controller.
For example (from the Oracle FXML Introduction), given the following markup:
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox xmlns:fx="http://javafx.com/fxml">
<children>
<fx:include source="my_button.fxml"/>
</children>
</VBox>
If my_button.fxml contains the following:
<?import javafx.scene.control.*?>
<Button text="My Button"/>
the resulting scene graph would contain a VBox as a root object with a single Button as a child node.
Dynamic Loading
Loading new fxml in the same scene describes how to load the new FXML files dynamically into a replaceable child Pane.
于 2013-09-19T05:31:53.447 回答