- 0
java Making JScrollBars behave
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
Download: Java All-in-One For Dummies, 7th Edition ($27 Value) — free for your email
By News Staff,
- ebook offer
- sponsored
- (and 3 more)
- 0 replies
- 2 views
-
Learn Java with Projects (worth $44.99) but free in exchange for your email
By News Staff,
- packt
- ebook offer
- (and 2 more)
- 0 replies
- 3 views
-
JavaScript from Frontend to Backend ($20.99 Value) FREE for your work email
By News Staff,
- ebook offer
- sponsored
- (and 3 more)
- 0 replies
- 3 views
-
- 0 replies
- 3 views
-
Job Ready Java ($24 value) free download for a Limited Time
By News Staff,
- ebook offer
- java
- (and 1 more)
- 0 replies
- 2 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
Share on other sites
1 answer to this question
Recommended Posts