JTextArea autoscroll

Hello all.

I'm using a JTextArea, and whenever I add text, it doesn't autoscroll to the bottom of the window, so as to display the just-inserted line.

I looked for a field or method for this, and thought setAutoScroll was what I needed, but it wasn't the case.

Does anybody know how I could get the JTextArea to always display the last line of text just inserted ?

Any thanks would be much appreciated.

Best regards,

Anton

[468 byte] By [MadAnta] at [2007-11-27 11:25:46]
# 1

int length = jTextArea.getDocument().getLength();

jTextArea.setCaretPosition(length);

c0demonk3ya at 2007-7-29 16:06:23 > top of Java-index,Desktop,Core GUI APIs...
# 2

scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum());

add this function

noobs_will_rulea at 2007-7-29 16:06:23 > top of Java-index,Desktop,Core GUI APIs...