java - JTextArea not updating dynamically -
i have jtextarea inside class want update dynamically. displaying text append after processing done. have tried implement following fix it:
public newconsole(){ initcomponents(); } public void write(final string s){ swingutilities.invokelater(new runnable() { public void run() { textarea.append(s); } }); }
console gets instantiated in parent class as:
protected newconsole console = new newconsole();
and output it, children call:
console.write("append this..");
edit: here's more information:
public abstract class parent{ protected newconsole console = new newconsole(); public parent(){} protected abstract int dosomething(); } public class child extends parent{ public child(){ console.write("i want update dynamically"); dosomething(); console.write("and this.."); } public int dosomething(){ //quite intensive processing here } }
the intensive processing done in dosomething
blocking edt
, preventing ui updates. use swingworker instead perform functionality.
use execute start worker. move required calls console.write
either doinbackground or done.
Comments
Post a Comment