Reputation: 780
<AnchorPane>
<TreeView fx:id="locationTreeView" focusTraversable="true" prefHeight="449.0" prefWidth="725.0" style="#tree { -fx-border-style:solid; -fx-border-width:1px; -fx-border-color:#ffffff; }"/>
In the above fxml code I want to add one more <TreeView>
but through the controller. How can I do this?
Upvotes: 0
Views: 149
Reputation: 40318
You will have to:
Give a fx:id
to the AnchorPane
:
<AnchorPane fx:id="theAnchorPane">
Add the corresponding field in the controller:
@FXML private AnchorPane theAnchorPane;
From the code that performs the addition you have to:
Create the new TreeView
however you like:
TreeView newTreeView = ...;
Add it to the childen of the AnchorPane
, possibly with some constraints:
theAnchorPane.getChildren().add(newTreeView);
AnchorPane.setTopAnchor(newTreeView, ...); // etc
Upvotes: 1