JTextArea and Thread
I call the following method from within a thread's run method:
public /*synchronized*/ void chatNotify( Message m )
{
textArea.append( m.getSender() + ": " + m.getMessage() + "\n" );
}
but nothing appears on the text area. I tried the method both with and without synchronized but no difference. Any idea?
Please post a Short,Self Contained, Compilable and Executable, Example Program and use code tags.
> It contains several classes! and by the way I have no
> problem with regualr applicaions using JTextArea.
> This happens only I call it from another thread.
Please post a Short,Self Contained, Compilable and Executable, Example Program.
It is hard for us to help if we are guessing what you coded. Creating a simple example isolates the problem, which will save time for anyone who helps you, normally you will find the problem on your own as you create this example.
And you are right, please don't post a bunch of classes. Just one class demostrating the problem will do.
> This happens only I call it from another thread.
It shouldn't matter. If you read the API you will see the the append(...) method is Thread safe.
My guess is you have to variables of the same name. One defined as a class variable and one as a local variable.
But we won't know for sure without an SSCCE.