Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an attempt to bring rounded border to
JScrollPane
and all component that are usually placed into a scrollpane. E.g.JTextArea
,JTextPane
,JEditorPane
,JList
,JTree
andJTable
.The problem is that there are multiple overlapping components involved:
JScrollPane,
which has the borderJViewport,
which has the view component as child (e.g. aJList
)JScrollBar
sThey are painted in this order and using rounded border on scrollpane would look like this:
The viewport/list and the scrollbar simply paint over the rounded corners.
And there is no way to fix this for the viewport in the look and feel.
(maybe a custom scrollpane implementation, that paints its border and corners after its children, could work)
So the idea to solve this problem is to add some extra space at left and right sides between the border and the viewport/scrollbars:
That's better, but the scrollbar should be at the border:
We can hide the scrollbar track and make the thumb round to improve the look:
If the vertical scrollbar is hidden, it looks like this:
With rounded selection (and smaller border arc than in previous screenshots) this looks really nice:
Here are some screenshot that shows the extra space, which was added for rounded border, in green:
Smaller border arc results in smaller extra space, larger arc gives larger extra space:
Possible improvements/ideas:
make viewport wider if vertical scrollbar is visible to remove the gap between viewport and vertical scrollbar (see above screenshot)allow specifying scrollpane border arc for component types (e.g. use rounded border for multi-line text components, but not for lists, tables and trees)For testing you need to enable rounded border. E.g.:
ScrollPane.arc = 12