Yup. That was the problem. I was trying to move the scroll bar from
another thread and needed to call SwungUitlities.invokeLater().
>
> ------------------------------
>
> Message: 7
> Date: Fri, 28 Dec 2007 01:11:15 -0700
> From: Doug Zwick <email@hidden>
> Subject: Re: JScrollBar error
> To: email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="us-ascii"
>
> James Rome wrote:
>
>
>> My App in Java 1.5 has a DefaultStyledDocument in a JScrollPane.
>> I keep adding more text to the Document and removing them when the
>> Document.length() > 20000.
>> (And by the way, if you ever do this, the Document saves all the
>> deleted
>> stuff unless you override methods in GapContent, which I do--
>> otherwise
>> you eventually run out of memory.)
>>
>> But I would like always to set the scroll bar to the bottom of the
>> Document after entering text. I do this using:
>> private void updateLength() {
>>
>
> ...
>
>
>> It works if I leave out the jsb.setValue chunk of code. What am I
>> doing
>> wrong?
>>
>
> The first thing I'd look for is a code path that could call
> updateLength on a thread other than the Swing thread. Add some code
> like this to updateLength:
>
> if (!SwingUtilities.isEventDispatchThread()) {
> System.err.println ("\n***** Not on EDT!");
> Thread.dumpStack();
> }
>
> (this is from memory, I may have some minor goof-ups in the above
> code, but it should illustrate the point)
>
> If the message appears, then updateLength has been called from
> another thread, and the stack trace will tell you how you got there.
> -
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden
This email sent to email@hidden