void exitMenuItem_actionPerformed(ActionEvent e) {   //exit
saveFile();
System.exit(0); //不推荐,建议用dispose(), 最后一个窗体关闭的时候,系统自然会退出
  }//-----
    this.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent ea ){
        saveFile();
        System.exit(0);
      }
    });
//----- 这段代码放到过早函数,或者jbInit()(如果你用的话)

解决方案 »

  1.   

    void exitMenuItem_actionPerformed(ActionEvent e) {   //exit
        this.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent ea ){
            saveFile();
            System.exit(0);
          }
        });
      }
    你好象在触发exitMenuItem_actionPerformed事件时又给窗体加了个关闭窗口的事件,
    但这个窗口关闭事件根本没出发,应该:
    void exitMenuItem_actionPerformed(ActionEvent e) {   //exit
        saveFile();
        System.exit(0);  //可以换成dispose();
    }