- 0
java Making JScrollBars behave
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
.NET and JDBC drivers get native vector data support, enabling up to 50x faster reads
By Usama Jawad96,
- 0 replies
- 0 views
-
JetBrains releases IntelliJ IDEA 2025.1.1, bringing multiple bug fixes and improvements
By David Uzondu,
- jetbrains
- intellij idea
- (and 6 more)
- 0 replies
- 0 views
-
- 14 replies
- 0 views
-
High Performance with Java ($33.99 Value) free eBook download
By News Staff,
- ebook offer
- sponsored
- (and 2 more)
- 0 replies
- 4 views
-
- 0 replies
- 8 views
-
Question
Seizure1990
I have a JScrollPane and JTextPane that is to be used in a chat program. Therefore, I'd like standard chat window behavior where the scroll bar continues to automatically scroll down if (and ONLY if) the scroll bar was already at the bottom, and otherwise leaves it at the current value.
The only solution I've found through searching which comes close to working involves setting the caret position for the JTextPane, but that still has issues. First, the relevant code:
chatView is a JScrollPane. The problem with this method is that even though the caret is set to the maximum value, the scroll bar will actually just be [i]ever-so-slightly[/i] away from all the way down. Then, when another message comes in, it doesn't think it should continue to scroll down since it's only close to bottom, but not actually.
What it looks like after the caret reset:
What it should look like:
Thanks for any help guys!
Link to comment
https://www.neowin.net/forum/topic/1110783-making-jscrollbars-behave/Share on other sites
1 answer to this question
Recommended Posts