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?
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));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.