java swing close window without exiting app

后端 未结 8 1467
慢半拍i
慢半拍i 2021-01-12 04:31

I have a little frame where I ask user & password. This frame will be opened clicking over a button in a main window.

Then I have two buttons: ok and cancel.

8条回答
  •  南笙
    南笙 (楼主)
    2021-01-12 05:10

    Make a function in outer class where you are implementing the JFrame (you need to close on pressing cancel button).
    Write this.setVisible(false); in the implementation of that function.
    Finally call this function in the ActionListener implementation when you want to close it.

提交回复
热议问题