How to wait for the JFrame to close before continuing?

My program consists of 3 main "sections". The main function, login form and application form. The main function should do something like: Open the login form, wait for it to close, and then open the application form. I can’t get the expected part to work, or rather, I don’t know how I will do it.

Someone told me to use JDialog instead and use setModal(true), but with this approach, the registration form will not appear on the taskbar, which is terrible in my opinion.

Another thing that I considered is to open the application from inside Login after closing it, but this seems like a bad design, as this will make the login form without reuse.

So please, what would you suggest?

+5
source share
1 answer
  • Why should the login appear on the taskbar, since the main application will be there, and you do not want more than one taskbar item for a separate program. Your best option might be to use a modal JDialog.
  • Another option is to use CardLayout to exchange views.
  • The third option is to use a JFrame if you have to attach a listener, it seems to me, to a WindowListener, in order to respond to its closed event.
  • No matter which route you go, your username should be JPanel so you can post it anywhere and then change your mind later.
+5
source

All Articles