Reputation: 9574
I am trying to load an FXML into an existing AnchorPane using:
@FXML
private AnchorPane content;
...
AnchorPane newPane = FXMLLoader.load(getClass().getResource("/fxml/scene2.fxml"));
this.content.getChildren().setAll(newPane);
And all that works well, but it destroys the layout of scene2.fxml, as it shows itself in prefered size. I would like to have it dynamically adapted though to the size of the parent FXML (basically have the size that the AnchorPane of scene1.fxml has).
What is wrong in my code? Where is the bug? How do I adapt the size of scene2.fxml automatically?
Upvotes: 0
Views: 1115
Reputation: 36722
Please see to it that you may have specified prefSize
to the AnchorPane
in scene2.fxml
. Children will only adapt to parent if there is no prefSize() assigned to them.
Have a look at
Upvotes: 0