How to programmatically close a JFrame

前端 未结 17 944
深忆病人
深忆病人 2020-11-22 05:42

What\'s the correct way to get a JFrame to close, the same as if the user had hit the X close button, or pressed Alt+F4 (on W

17条回答
  •  隐瞒了意图╮
    2020-11-22 06:26

    This answer was given by Alex and I would like to recommend it. It worked for me and another thing it's straightforward and so simple.

    setVisible(false); //you can't see me!
    dispose(); //Destroy the JFrame object
    

提交回复
热议问题