Reputation:
I have a StackPane, which is inside a ScrollPane. I want that minimal size of StackPane was as the size of ScrollPane. This is my code
stackPane.minWidthProperty().bind(scrollPane.widthProperty());
stackPane.minHeightProperty().bind(scrollPane.heightProperty());
However, using this code the scroll bars (vertical and horizontal) are always visible and there is a small scrolling. I suppose that I include scroll bar size in minimal size of StackPane. How can I make StackPane minimal size be equal to ScrollPane and scroll bars are not visible if they are not needed?
Upvotes: 3
Views: 866
Reputation: 55
Late Answer but maybe someone needs a solution.
All you need to do is to add a small offset like that:
stackPane.minWidthProperty().bind(scrollPane.widthProperty().subtract(20));
stackPane.minHeightProperty().bind(scrollPane.heightProperty().subtract(20));
Upvotes: 1