JTextArea / JScrollPane Question

Hello,

In my application I have a 15 x 15 JTextArea with a JScrollPane. This scroll pane has both vertical and horizontal scrollbars. When I insert new data into the JTextArea, I do the following:

dataDisplay.insert("blah blah blah\n",0);

What this does is inserts the data at the beginning, and pushes the rest of the data down. The problem I am having is after it reaches the bottom line, it will start to scroll downward. What I need it to do is reset the position back to the top, without scrolling downward, but I still need to be able to scroll downward if I need to(so removing the scrollpane would not be an option). I looked at the different methods of JTextArea and JScrollPane and cannot find a function that would do this.

Any ideas?

[801 byte] By [doleary86a] at [2007-11-26 14:27:16]
# 1
textPane.insert(...);textPane.setCaretPosition(0);
camickra at 2007-7-8 2:20:48 > top of Java-index,Desktop,Core GUI APIs...
# 2
Excellent! Thank you very much, worked perfectly!
doleary86a at 2007-7-8 2:20:48 > top of Java-index,Desktop,Core GUI APIs...