清华书上的能关闭窗口的代码:(一字不差!)
但就是抱错:
"MyFrameCanExit.java": MyFrameCanExit should be declared abstract; it does not define windowClosing(java.awt.event.WindowEvent) in MyFrameCanExit at line 4, column 1*************************************
import java.awt.*;
import java.awt.event.*;public class MyFrameCanExit extends Frame implements WindowListener{
  public static void main(String[]args){
    MyFrameCanExit fr = new MyFrameCanExit("hello!");
    fr.addWindowListener(fr);
    fr.setSize(200,200);
    fr.setBackground(Color.green);
    fr.setVisible(true);
  }
  
  public MyFrameCanExit(String str){
    super(str);
  }
  
  public void windowsClosing(WindowEvent e){
    System.exit(0);
  }
  
  public void windowClosed(WindowEvent e) {}
  public void windowOpened(WindowEvent e) {}
  public void windowIconified(WindowEvent e) {}
  public void windowDeiconified(WindowEvent e) {}
  public void windowActivated(WindowEvent e) {}
  public void windowDeactivated(WindowEvent e) {}
  
}