-
Bug
-
Resolution: Incomplete
-
P3
-
None
-
8
One major usecase for the ScrollPane is when you can wrap the component in it and get the same behavior when component is small enough for the available area and scrollbars appearing when it is too big.
In practice it doesn't work like this in many cases.
One of the problem is that ScrollPane is not resized to the content of its node. A possible solution is to bind its prefViewportWidth/Height to the content width as following:
scrollPane.prefViewportWidthProperty().bind(content.widthProperty());
It also requires to do the following:
scrollPane.setMaxWidth(ScrollPane.USE_PREF_SIZE);
scrollPane.setMaxWidth(ScrollPane.USE_PREF_SIZE);
Unfortunately, even using this it works differently depending on scroll bar policy.
When it is ALWAYS, then scrollbar width is added to prefViewportWidth value and everything is fine. The only exception is that scrollbar is always there even if the content is not big enough.
When it is AS_NEEDED, then scrollbar width is not added to prefViewportWidth value and scrollbar appear on top of the content.
In practice it doesn't work like this in many cases.
One of the problem is that ScrollPane is not resized to the content of its node. A possible solution is to bind its prefViewportWidth/Height to the content width as following:
scrollPane.prefViewportWidthProperty().bind(content.widthProperty());
It also requires to do the following:
scrollPane.setMaxWidth(ScrollPane.USE_PREF_SIZE);
scrollPane.setMaxWidth(ScrollPane.USE_PREF_SIZE);
Unfortunately, even using this it works differently depending on scroll bar policy.
When it is ALWAYS, then scrollbar width is added to prefViewportWidth value and everything is fine. The only exception is that scrollbar is always there even if the content is not big enough.
When it is AS_NEEDED, then scrollbar width is not added to prefViewportWidth value and scrollbar appear on top of the content.