java - Using Swingworker to constantly update a GUI -
in code, user presses button, , want invoke swingworker background thread, loop through list, cross reference other data, , update gui jlabel every pass through loop. problem know should in doinbackground(), have nothing return, , want update jpanel new jlabel every time loop loops. how do this? thanks!
here complete example swing worker example
you have use publish()
, override process()
example:
class worker extends swingworker<void, string> { @override protected void doinbackground() throws exception { //here make heavy task running in thread not in edt //process after time call publish() } @override protected void process(list<string> chunks) { //this executed in edt //here update label } }
Comments
Post a Comment