java - Why is my JTextArea not updating? -


i have code follows:

class simplifiedclass extends japplet {      private jtextarea outputtext;     // lots of methods     public void doeverything() {         string output = "";         for(int = 0; <= 10; i++) {             output += taskobject.somelongtask(i);             outputtext.settext(output);         }     } } 

however, instead of updating text area after each iteration of loop when settext called, appears update text when runs of task done. why happen, , how can resolve it?

you're using swing thread waiting code execute before can update ui. try using separate thread loop.

public void doeverything() {   swingutilities.invokelater(new runnable() {     public void run() {       string output = "";       for(int = 0; <= 10; i++) {         output += taskobject.somelongtask(i);         outputtext.settext(output);       }     }   }); } 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -