Re: ScrollPane - automatic scrolling

From: Babu Kalakrishnan (k.a.l.a_at_sankya.com)
Date: 03/23/04


Date: Tue, 23 Mar 2004 14:13:32 +0530

Andrew Thompson wrote:
> On Tue, 23 Mar 2004 07:50:18 +0100, vertigo wrote:
>
>
>>I have JTextArea in ScrollPane with VERTICAL_SCROLLBAR_ALWAYS.
>
>
> <http://www.physci.org/codes/javafaq.jsp#cljg>
>
>>When i append text to JTextArea, ScrollPane do not scroll (always shows
>>the eldest text, in the begining of JTextArea).
>
>
> That sounds odd, I thought the default behaviour
> was to show the last appended text..
>

I believe this (failure to scroll to the bottom) happens when the text
is appended from a thread that isn't the Event Dispatch Thread.

Wrapping the append call in SwingUtilities.invokeLater wrapper should
fix this.

BK



Relevant Pages