PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Textarea automatisch Scrollen?



100
01.05.2010, 22:16
Hey, ich hab ein Textarea Steuerelement, welches ich als Log verwende.. also es kommen immer mal ein paar Zeilen hinzu. Nun ist es ja toll, dass das Steuerelement von sich aus Scrollbars hat, allerdings ist es unpraktisch, dass hinzugefügter Text ohne ständiges Runterscrollen nicht zu sehen ist.

Frage nun, gibt es eine Methode mit der ich es irgendwie erreichen kann, dass das Textfeld bis zum Ende scrollt?

Mfg

EBFE
01.05.2010, 23:32
Woimit addest du den zusätzlichen Text?
schau dir eventuell
How to Use Text Areas (The Java� Tutorials > Creating a GUI With JFC/Swing > Using Swing Components) (http://java.sun.com/docs/books/tutorial/uiswing/components/textarea.html)
an:



textArea.append(text + newline);
Unless the user has moved the caret (insertion point) by clicking or dragging in the text area, the text area automatically scrolls so that the appended text is visible. You can force the text area to scroll to the bottom by moving the caret to the end of the text area after the call to append:

textArea.setCaretPosition(textArea.getDocument().g etLength());
:)