Hello, in this code suppose that the dlg is defined in one case as a JDialog, I run it and it seems that the JDialog is executed AFTER closing it, so the message is printed after closing the JDialog. But when I run the code with dlg defined as JPanel it prints the message before I close the JPanel.
And I need the JPanel to behave like the JDialog in that sense.. how could I deal with this? Thanks in advance
I run it and it seems that the JDialog is executed AFTER closing it, so the message is printed after closing the JDialog.
I would imagine that what is happening is your JDialog is modal so it is effectively blocking the current thread when it is displayed. Once you close the dialog the method's execution continues so prints out "I'm Here".
I don't understand what you mean by closing a panel because you can't close a JPanel in the same way as a JDialog or JFrame, how are you closing it?
BTW Before attempting to perform your own block be careful because if you just block the event thread your GUI will lock up.