I put this question a month ago and got the answer that one can use the function setCaretPosition(). It works. But if the text is getting langer and longer, it takes long time to get the text printed out. I think there must be another betther methor to do that, such as set the scrollbar postion etc.
Here is my question again:
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?