关于windowListener的问题
import java.awt.*;import java.awt.Event.*;
import java.awt.Window.*;
class W implements WindowListener{
Frame f;
public static void main(String[] args){
W w=new W();
}
W(){
f=new Frame("george");
f.addWindowListener(this);
f.setVisible(true);
}
public void windowClosing(WindowEvent e){
System.out.println("windowclosing");
}
public void windowOpened(WindowEvent e){
System.out.println("windowopened");
}
public void windowIconified(WindowEvent e){
System.out.println("windowIconified");
}
public void windowDeiconified(WindowEvent e){
System.out.println("windowDeiconified");
}
public void windowClosed(WindowEvent e){
System.out.println("windowclosed");
}
public void windowActivated(WindowEvent e){
System.out.println("windowActivated");
}
public void windowDeactivated(WindowEvent e){
System.out.println("windowdeactivated");
}
}
为什么编译说:w.java:11: 无法将 java.awt.Window 中的 addWindowListener(java.awt.event.WindowLi
stener) 应用于 (W)
f.addWindowListener(this);
编译有很多的错误,我只弄了最后的一行!!
不太明白,顶级容器不能授权监听器吗???
请教高手了!!!