实现窗口关闭怎么实现不了?
package zdkj.wzq.java11;import java.awt.Button;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
public class WindowApp1 extends JFrame
implements WindowListener{
Button close=new Button("退出程序");
public WindowApp1(){
super("窗体事件");
this.add(close);
//方法二:对窗口实现监听
this.addWindowListener(this);
Container c=this.getContentPane();
this.setLayout(new FlowLayout());
c.add(close);
this.setSize(200,250);
c.setBackground(Color.green);
this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new WindowApp1();
}
@Override
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}
@Override
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
}
}