首先在主函数中设置监听器:
f.addWindowListener(new MyWin());
监听器类是这样设置的:
class MyWin extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.out.println("window closing ____"+e.toString());
System.exit(0);
}
public void windowActivated(WindowEvent e)
{
System.out.println("active");
}
public void windowOpened(WindowEvent e)
{
System.out.println("Opened");
}
}
现在,我就是很想知道类WindowAdapter的几个处理时间的函数的参数都是WindowEvent,产生了事件,比如说我关闭了窗口,系统是如何判断调用MyWin这个类中的哪个函数呢?系统在底层是如何做的?
|