From: Knute Johnson on
On 1/21/2010 7:04 AM, John B. Matthews wrote:
>
> Why? The append() method is thread safe.
>
> <http://java.sun.com/javase/6/docs/api/javax/swing/JTextArea.html#append(java.lang.String)>
>

The behavior of the caret changes depending on whether the append()
method is called on the EDT or not (as of 1.5 that is easily changed
however). Also, you might want to do it for visibility or
synchronization purposes. If you want to put the JTextArea in a
JScrollPane and scroll to the caret, that will need to be done on the
EDT as well.

I think the OPs problem lies in the code we don't see however.

--

Knute Johnson
email s/nospam/knute2010/

From: Lew on
Peter Duniho wrote:
> Now, all that said, I think none of this has answered your original
> question, which is why the text does not appear immediately.  Without a
> SSCCE it's impossible to say for sure what might be the cause of that.
> But keep in mind that repainting of Swing components (or AWT for that
> matter) does not necessarily happen immediately.  The system tracks what
> components need redrawing (it's "invalidated"), and then at some
> indeterminate time shortly after the invalidation happens, it's actually
> redrawn.
>

Or the problem is not a Swing or EDT issue and has to do with
PrintStream being buffered and not flushed.

--
Lew
From: Peter Duniho on
Lew wrote:
> Peter Duniho wrote:
>> Now, all that said, I think none of this has answered your original
>> question, which is why the text does not appear immediately. Without a
>> SSCCE it's impossible to say for sure what might be the cause of that.
>> But keep in mind that repainting of Swing components (or AWT for that
>> matter) does not necessarily happen immediately. The system tracks what
>> components need redrawing (it's "invalidated"), and then at some
>> indeterminate time shortly after the invalidation happens, it's actually
>> redrawn.
>>
>
> Or the problem is not a Swing or EDT issue and has to do with
> PrintStream being buffered and not flushed.

Could be. If so, the OP misstated his problem, as he wrote a comment
claiming that his updateTextArea() method does append, but that the
update isn't shown. That implies the OP has in fact verified that the
updateTextArea() method is being called.

Wouldn't be the first time someone posted code in which they made an
incorrect assertion about what the code does. :)

Pete
From: Mike Schilling on
Peter Duniho wrote:

>
> Wouldn't be the first time someone posted code in which they made an
> incorrect assertion about what the code does. :)

At leasst half the point of posting code is to show it to people
making different assumptions.