您的位置:首页 > 编程语言

Swing代码分析(事件监听方法二)

2010-02-21 10:21 567 查看
]package nau.ui;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

/**
* 功能:
*
* @author wzj
*
*/
public class SwingWinAdapterTestTool extends JFrame {

/**
*
*
*/
public SwingWinAdapterTestTool() {

this.setVisible(true);
this.setTitle("SwingWinAdapterTestTool");
this.setBounds(100, 100, 400, 200);
this.setLayout(null);

// 窗口关闭时间失效
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

this.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {
System.out.println("closing window");
// SwingWinAdapterTestTool.this.setVisible(true);// 刷新窗口
System.exit(0);
}
}

);

}

/**
*
* @param args
*/
public static void main(String[] args) {
new SwingWinAdapterTestTool();
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: