为什么对windowClosing方法中的代码要进行重新编写,若不覆盖原来的windowClosing方法,点击窗口“x”则不能关闭窗口。
为什么不用重新编写windowDeiconified方法,点击窗口能够最大化。
package cn.com.test;
import java.awt.*;
import java.awt.event.*;
public class FrameTest {
public static void main(String[] args)
{
Frame f=new Frame("IT人才资讯交流网");
f.setSize(300,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 windowOpened(WindowEvent e){};
public void windowDeiconified(WindowEvent e){};
public void windowIconified(WindowEvent e){};
public void windowDeactivated(WindowEvent e){};
}