Show always last line on textarea

Hi java world,

i have a textarea as viewport of a scrollpane. When new text is added into text area , the lines go under scroll. I want that when the the lines are added, always my last text (last line) is shown. How can i do this.?

scrollPane1 =new JScrollPane();

textArea1 =new JTextArea();

textArea1.setColumns(25);

textArea1.setRows(5);

textArea1.setEditable(false);

textArea1.setFocusable(false);

scrollPane1.setViewportView(textArea1);

[638 byte] By [asilazmaza] at [2007-11-27 11:56:37]
# 1

textArea1.setCaretPosition(textArea1.getDocument().getLength());

Regards,

Stas

StanislavLa at 2007-7-29 19:08:36 > top of Java-index,Desktop,Core GUI APIs...
# 2

thanks very much..

asilazmaza at 2007-7-29 19:08:36 > top of Java-index,Desktop,Core GUI APIs...