做了一个关闭窗体的一个小功能,代码如下::- import java.awt.*;
- import java.awt.event.*;
- public class TestFrame
- {
- public static void main(String [] args)
- {
- Frame f=new Frame("窗体测试窗口");
- f.setSize(500,300);
- f.setVisible(true);
- f.addWindowListener(new MyWindowListener());
- }
- }
- class MyWindowListener implements WindowListener
- {
- public void windowClosing(WindowEvent e)
- {
- e.getWindow().setVisible(false);
- ((Window)e.getComponent()).dispose();
- System.exit(0);
- }
- public void windowActivated(WindowEvent e){}
- public void windowClosed(WindowEvent e){}
- public void windowDeactivated(WindowEvent e){}
- public void windowDeiconified(WindowEvent e){}
- public void windowIconified(WindowEvent e){}
- public void windowOpened(WindowEvent e){}
- }
复制代码 我的疑问是我只想调用关闭的功能,那么只调用windowClosing()这个方法就可以了,为什么还要调用以下方法呢 ??
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){}
|