I have got a GUI design problem which I would get help on. Suppose I have an desktop app. The app has a main window(JFrame). In the main window, there is a JButton. After clicking the JButton, the app would run some heavy execution which may take one or two minute to complete. While the execution is running, the window and UI controls will become not responsible because the execution is running on the same
thread with the JButton's action thread. Therefore I thought it would be a good idea to show a JDialog with a waiting message before starting the execution. When the execution has finished, the thread can close/dispose the JDialog waiting screen. The JDialog has parent of the main window so it can block off any input directly to the main window. The JDialog also has got its close button disabled so users are not able to close the JDialog while the execution is running.
Here is what I do (not exact code):
Now the problem is, the dialog comes up and the thread is waiting for the users to close the dialog to continue, but because the close button is disabled, the thread is halted. So basically the thread got stuck and runExecution() is never run!
I am just wondering how would an experienced GUI developer would write their loading screen. Personally, I think I could solve the problem by creating another thread to handle the dialog waiting screen, but I really want to avoid creating additional thread where possible. My app's threading is messy enough but just about manageable. I don't want to make it worse.