且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在不退出JVM/Application的情况下关闭并打开JFrame?

更新时间:2021-08-26 22:28:44

我用Google搜索并找到了解决方案,是这样的:

I googled and i find the solution, and is this:

       WindowEvent closingEvent = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
       Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(closingEvent);
       frame.setVisible(true);

它使用WindowEvent进行与"x"点击相同的操作.

It uses a WindowEvent to do the same as "x" click does.

无论如何,谢谢你们的帮助!

Thank you guys anyway for your help!!!