Reputation: 2098
I have a TabPane
which contains two Tab
s and is set up in FXML
. On initialization I dynamically add an AnchorPane
to one of the Tab
s. I then set a ListView
as a child of the AnchorPane
:
AnchorPane questionPane = new AnchorPane();
questionPane.setId("questionPane");
ListView questionList = new ListView();
questionPane.getChildren().add(questionList);
This works perfectly fine. For debugging purposes I gave the AnchorPane
an orange background (via CSS
) and when I now resize the window, the AnchorPane
get's resized as expected.
But as soon as I add the following line to the code, the AnchorPane
can only grow and doesn't shrink anymore, resulting in outsizing my window:
questionList.prefWidthProperty().bind(questionPane.widthProperty());
Can anyone please explain, why this line breaks the resizing of the AnchorPane
?
Upvotes: 0
Views: 767
Reputation: 1097
Most likely you didn't specify the anchoring of the ListView:
AnchorPane.setBottomAnchor(questionList , 8.0);
AnchorPane.setRightAnchor(questionList , 5.0);
AnchorPane.setTopAnchor(questionList , 8.0);
AnchorPane.setLeftAnchor(questionList , 5.0);
The binding is not needed anymore.
Upvotes: 1