Link to home
Start Free TrialLog in
Avatar of chenwei
chenwei

asked on

How to set the scrollbar always at the bottom

My program has a JScrollPane, it contains a JTextArea. The program will read in text and print it onto the JTextArea. But as the text getting large and longer, the scrollbar moves up-words. I have to use the mause to droll the scrollbar to the bottom so I can see the whole text. How can I set the scrollbar always on the bottom of the textarea as text is printed?
Avatar of girionis
girionis
Flag of Greece image

If I understand correctly you need to display the text area as the text occupies more and more of the screen. Use the setCaretPosition() and pass it the length of the text. Thsi will make the text area visible to the last line always.
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kimos123
kimos123

use  printed text + new text