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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
use printed text + new text
:)