A scrollable control, such as ScrollPane, TextField, or WebView has a size that is distinct from the size of its content. If the size of the scrollable control is smaller than the size of its content, scrollbars are added to allow the portion of the content that is shown to be scrolled. If you embed one or more scrollable controls within an outer ScrollPane, each of them will have their own scrollable region and scroll bars. The preferred size of a scrollable control, which is used when that control is laid out in a parent container, is a fixed size that is not based on the size of its content. This makes it infeasible to support an application that wants to include scrollable components within an outer ScrollPane, and lay them out in a seamless manner with each control being sized to the size of its content.
We should explore adding new properties to at least ScrollPane, TextField, and WebView to enable taking the width / height of the scrollable component from the width / height of its content, completely disable scrolling in the horizontal / vertical direction.
Some initial thoughts are captured in the following GitHub document:
https://gist.github.com/kevinrushforth/17c63d854f817d9efa176ec6090c85bc
The implementation for ScrollPane is expected to be fairly straight-forward. One that is done, it will be easy to implement it for TextArea, since the TextAreaSkin uses ScrollPane in its implementation.
The implementation for WebView will likely be a bit more involved given its custom implementation of scrollbar, so we might split adding this to WebView out into a separate RFE.
We should explore adding new properties to at least ScrollPane, TextField, and WebView to enable taking the width / height of the scrollable component from the width / height of its content, completely disable scrolling in the horizontal / vertical direction.
Some initial thoughts are captured in the following GitHub document:
https://gist.github.com/kevinrushforth/17c63d854f817d9efa176ec6090c85bc
The implementation for ScrollPane is expected to be fairly straight-forward. One that is done, it will be easy to implement it for TextArea, since the TextAreaSkin uses ScrollPane in its implementation.
The implementation for WebView will likely be a bit more involved given its custom implementation of scrollbar, so we might split adding this to WebView out into a separate RFE.
- relates to
-
JDK-8091714 [TextArea] add option about resizing to fit content.
- Open