I have developed a simple swing application in which i am running a process using SwingWorker and showing an indeterminate progress bar to end user while the process is running.
As soon as the process is complete I am setting the visibility of ProgressDialog false in done() method of SwingWorker.
Now the problem is when end user clicks on parent window it is getting focused and progress dialog is going back to the main window which I don't want when i tried to set modality of dialog as true it is holding my program there only and my SwingWorker thread doesn't start at all.
As I am a very new for Swing let me know how can I achieve both things together.
My swingworker should stop as well as user should not be able to click on main as happened when we set modality tru for a dialog.
Code Snippet :
ProgressDialog myProgressDialog = new ProgressDialog();
myProgressDialog.setVisible(true);
myProgressDialog.setLocationRelativeTo(this);
mySwingWorkerForUpdate = new SwingWorker<String, String>() {
@Override
protected String doInBackground() throws Exception {
//my code here
}
@Override
protected void done() {
super.done();
mySwingWorkerForUpdate = null;
myProgressDialog,setVisibility(false);
}
};
mySwingWorkerForUpdate.execute();