java - Show a JFrame while waitFor another process to end -


in application when backup button pressed, take time create database backup, need display jframe contains "please wait.." message, , want dispose when backup process completed. following code, never shows jframe, application stuck until process ends.

try {              waitview wait = new waitview();             wait.setlocationrelativeto(null);             wait.setvisible(true);              process p = runtime.getruntime().exec("cmd /c mysqlbackup.bat", null, new file("c:\\mysqlbackups"));                         p.waitfor();              wait.dispose();              messageservice.showmessagedialog(messageservice.backup_successful, "successful", "info");          } catch (exception ex) {             ex.printstacktrace();         } 

wrap code in swingutilities.invokelater()

        process p = runtime.getruntime().exec("cmd /c mysqlbackup.bat", null, new file("c:\\mysqlbackups"));                     p.waitfor();          wait.dispose();          messageservice.showmessagedialog(messageservice.backup_successful, "successful", "info"); 

but it's better run succh ong tasks in separate thread. check swingworker examples.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -