java - Searching thousands of files via a thread and "tree walker", writing matches to JTable results in unresponsiveness -


i have revised windows 7 search program write matched files jtable. prior writing jtextarea. output ugly; hence jtable output. jtable, program becomes unresponsive time time if searching thousands of files. (not jtextarea. smooth.)

my question how improve responsiveness.

i have 1 thread invoked in main , "walks file tree" given node:

  public static void main(string args[]) {       eventqueue.invokelater(new runnable() {         public void run() {           gui = new gui();           utilities.disable(gui.btnstop);         }});         t = new thread(new task());      taskstarted = false;   } } 

here's class header task:

public class task extends simplefilevisitor<path> implements runnable{ 

here's run:

  public void run()    {       searchygui.disposition = filevisitresult.continue;       files.walkfiletree(path , this);   } 

here's main routine tree walking (there 3 others, 1 processing directories, 1 post-processing them, , 1 errors):

  public filevisitresult visitfile(path f, basicfileattributes a) throws ioexception {     if(a.issymboliclink())       return searchygui.disposition;     file file = new file(f.getparent().tostring(), f.getfilename().tostring());     try      {       if(f.getfilename().tostring().tolowercase().matches(fpatt.tolowercase().trim())           report(s);     } catch (malformedurlexception | saxexception | tikaexception ex) {msgbox(ex.tostring());}     return searchygui.disposition;   } 

matched files , info written jtable:

      private static void report(...){         arraylist<string> rowdata = new arraylist<>(4);               rowdata.add(date);               rowdata.add(size);               rowdata.add(filename);                   rowdata.add(path);               dfttablemodel.addrow(new object[]{rowdata.get(0),rowdata.get(1),rowdata.get(2),rowdata.get(3)});           }           catch (exception e)           {              searchygui.disposition = filevisitresult.terminate;           }       } 

to improve responsiveness, don't know if need thread writing jtable or if need use swingworker. in either case, i'm not sure how go implementation.

assuming thread, turn report method class implements runnable? i'm having trouble visualizing implementation can figure out if have to.

i once used swingworker, incorrectly (with no thread), program. gave when output area flashed incessantly. i'm not keen on going route, figure out if advisable.

i don't think question falls in "opinion" area. need advice on how improve responsiveness. don't want head down wrong path if can point error in doing in advance.

enter image description here


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -