How to wait for a JFrame to close before continuing?

后端 未结 1 1240
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-11 19:44

My program consists of 3 main \'sections\'. Main function, Login form and App form. The main function should do something like: Open Login form, wait for it to close, then o

1条回答
  •  囚心锁ツ
    2020-12-11 20:15

    • Why must the login appear on the task bar, since the main app will be there, and you don't want more than one task bar item for an individual program. Your best option may be to use a modal JDialog.
    • Another option is to use CardLayout to swap "views".
    • A third option is to use a JFrame if you must but attach a listener to it, a WindowListener I believe, to respond to its close event.
    • Regardless of which route you go, your login gui should be a JPanel so that you can place it anywhere you wish and then change your mind later.

    0 讨论(0)
提交回复
热议问题