I am writing an app that requires the user to enter some data into a Swing GUI which the app will then use. After the user enters the data, there is no longer any need for the GUI as the app will then write some data to files.
The General idea is this:
launchGui();
closeGui();
continueWithComputation();
I understand that Swing uses a few threads in the background which I understand is why the program doesn't block until the GUI is closed.
Is it possible in any way to wait for the GUI to close (single JFrame
closed with dispose()
) before continuing with continueWithComputation()
?
Wait for Swing GUI to close before continuing
Use a modal dialog. See the following for further details:
Is it possible in any way to wait for the GUI to close (single JFrame closed with dispose()) before continuing with continueWithComputation()?
user actions add WindowListener
from code to call JFrame#setVisible(false)
, then you can running continueWithComputation()
, you have to close this JVM by System.exit(0)
, otherwise stays in PC's RAM untill restarted or power-off
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With