Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I move a JScrollbar of a JScrollPane?

807591Jun 19 2008 — edited Jun 19 2008
Hello! I have a program in which I have a JScrollPane wrapping a JTextArea object. Whenever I set the text of the JTextArea to something fairly large, the JScrollPane automatically scrolls to the end of the JTextArea... leaving me with 2 questions.

1. How can I prevent a JScrollPane from automatically scrolling to the end of the JTextArea whenever I set the text of the JTextArea to a large block?

2. How can I programmatically move the position one of the JScrollPane's JScrollbars? In specific, I'd like to reset the Vertical scrollbar back to the top. I've tried using setValue(0) of the JScrollbar after calling the getVerticalScrollbar, but although it has changed the value (a call to getValue() shows it has been modified), it hasn't actually moved the scrollbar


I would REALLY appreciate any help... I'm new at using Swing and I kinda need this for work... Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2008
Added on Jun 19 2008
3 comments
1,357 views