Show JDialog ("Please Wait") on JFrame

or123456 picture or123456 · Jan 8, 2012 · Viewed 30.4k times · Source

I have a JFrame and this JFrame has a JButton.

I want in JButton first show JDialog (display "Please wait") and execute other code then closing JDialog.

But when showing JDialog stopped to execute other code on JButton.

Answer

Andrew Thompson picture Andrew Thompson · Jan 8, 2012

Start the other processing on a Thread (e.g. in a SwingWorker) and at the start of it, call modalDialog.setVisible(true). At the end of the task call setVisible(false).