Java GUI - SwingWorker and gif -


ok doing taks of parsing data document in swingworker takes quite amount of time. , showing "loading gif" jbutton icon while doing , updating label every 15% done. working ,but problem gif moving or sometiems stop sec , start again. gif not animating smooth. jbutton disabled , set gift icon disabled jbutton.

in maingui class:

jbutton3.setdisabledicon(new javax.swing.imageicon(getclass().getresource("/images/loading.gif"))); 

after user click on button call this:

        runloader=new cashloader(jbutton3, jlabel2, ucty, userlock);         jbutton3.setenabled(false);         jlabel2.setforeground(color.gray);         executor.execute(runloader); 

cashloader thread this:

 @override     protected object doinbackground() {       // long code here       // somewhere in code call evey 15% done this:       publish(new publishingclass(sum, true));     }  @override protected void process(list<publishingclass> sum){     (publishingclass publishingthing : sum) {         if (publishingthing .isorangecolor()) lblsum.setforeground(new color(226,182,3));         lblsum.settext(""+publishingthing .getnumber()+" %");     } }  @override protected void done(){     btnreload.setenabled(true);    ... } 

thats sorter version of code. can see not doing in swingworker doinbackground() method jbutton. once set disabled should show gif icon. doing ,but not smooth ,it stops few seconds or once move mouse on window starts moving gif . basicly shows laggy gif.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -