java - "Please wait" message with delay -


i have long task , show "please wait" message during execution. use swingworker it. long task not long, want show message 1 second delay, don't know how it.

swingworker<void, void> myswingworker = new swingworker<void, void>(){      @override     protected string doinbackground() throws interruptedexception          /** execute operation */        }     @override     protected void done() {         dialog.dispose();     }   };    myswingworker.execute();    jprogressbar progressbar = new jprogressbar();   progressbar.setindeterminate(true);   jpanel panel = new jpanel(new borderlayout());   panel.add(progressbar, borderlayout.center);   panel.add(new jlabel("please wait......."), borderlayout.page_start);   dialog.add(panel);   dialog.pack();   dialog.setlocationrelativeto(win);   dialog.setvisible(true); 

}

before start swingworker, start swing timer (at least) 1 second delay , set not repeat.

pass timer swingworker has access it. when worker's done method called, stop timer

if timer triggered, display wait message.

with little bit of effort, wrap whole thing in self contained class, using swingworker's propertylistener support detect when worker started , completed


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -