I have a save button in a JFrame ;on clicking save the ‘save’ text sets to ‘saving….’; I need to set that text as ‘saved’ after a delay of 10 seconds.How is it possible in java?
Please help…
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
This is what i did…but this wont shows as ‘saving’ during that delayed time.
If you want to provide the user with visual feedback that something is going on (and maybe give some hint about the progress) then go for
JProgressBarandSwingWorker(more details).If on the other hand you want to have a situation, when user clicks the button and the task is supposed to run in the background (while the user does other things), then I would use the following approach:
Finally, the initial solution that was using the
Swingspecific timer: