你不要写这个方法不就好了吗?

解决方案 »

  1.   

    先在构造函树里确定这个 JFrame 的缺省 CloseOperation 为 DO_NOTHING_ON_CLOSEsetDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);这样你点击右上角的关闭按扭的时候窗口就不会退出了
    但这是他仍然可以接受 windowClosing 事件
    这是你就可以在void this_windowClosing(WindowEvent e) {
      // your code goes here
    }中弹出你的对话框 用户确认后
    用 System.exit(0); 退出
      

  2.   

    应该可以复写关闭事件吧
    关注