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
Post a Comment