I am sorry, for I believe that this question has been asked already, but none of the answers have actually helped me out. I have a class with gui, it contains a JFrame with several textfields and buttons. Here's the main() I'm trying to get working:
Gui interface1 = new Gui();
interface1.setSize(200,200);
interface1.setVisible(true);
//hold main execution
//wait for the pressed button in gui
//close the jframe
//proceed with main()
call_some_functions();
I have tried setting default close operation to HIDE_ON_CLOSE but that doesn't seem to be what I want. I'm using a framework and I need main() to be alive for quite a long time. Basically, I need jframe to hold the main() for the time of user input and updating parameters, then close itself without terminating the process and continue with main() as if nothing has happened. Thanks in advance for any help.
Uses a JDialog
instead of JFrame
and make the JDialog
modal, using JDialog#setModal
to true
See How to use dialogs for more information