JTextArea won't update

Could any of you please help me with this problem: I have a JTextArea that needs to update while my program is running. The method that should do the update, looks like this:

public void alg()

{

.....

for (int t=0;t<this.nr_gen1;t++)

{

String s=new String("t= "+t+"\n");

this.jta.append(s);// jta is the JTextArea

this.jta.updateUI();

try{

Thread.currentThread().sleep(600);

} catch(Exception e){

}

}

.........

}

Well, if I call this method from main, it updates the JTextArea while the program is running. But if I call it from a button's ActionPerformed method, the JTextArea won't update and the results are displayed in the JTextArea only when the program finishes.

I would be very grateful if you could help me with this.>

[847 byte] By [Iuliana_Bocicora] at [2007-11-27 8:50:50]
# 1
Thread.sleep() does never get along really well with gui ;if you intend to use it, i suggest that you open up a new thread to execute the specific list of instructions related to the button listener
calvino_inda at 2007-7-12 21:02:50 > top of Java-index,Java Essentials,Java Programming...
# 2
Swing related questions should be posted in the Swing forum.In addition to the above advice, get rid of the updateUI() method.
camickra at 2007-7-12 21:02:50 > top of Java-index,Java Essentials,Java Programming...
# 3
Thank you, I will try that.
Iuliana_Bocicora at 2007-7-12 21:02:51 > top of Java-index,Java Essentials,Java Programming...
# 4
It worked...with a new thread...Thansk again !
Iuliana_Bocicora at 2007-7-12 21:02:51 > top of Java-index,Java Essentials,Java Programming...