-
-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scrollpane rounded border #713
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Aug 13, 2023
Closed
…ce gap between view and vertical scrollbar
Very good work, can I already use that as a Snapshot or something like this? |
…xt components, lists, tables and trees
DevCharly
force-pushed
the
scrollpane-rounded-border
branch
from
November 25, 2023 22:29
8a61f79
to
b1fdbde
Compare
Last commit adds possibility to specify scroll pane arc for multi-line text components, lists, tables and trees. There are four new UI properties that have default value ScrollPane.List.arc = -1
ScrollPane.Table.arc = -1
ScrollPane.TextComponent.arc = -1
ScrollPane.Tree.arc = -1 E.g. if you want rounded border only for multi-line text components, then simply use: ScrollPane.arc = 0
ScrollPane.TextComponent.arc = 12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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