| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 724 人关注过本帖
标题:关于windowListener的windowClosed()的方法调用!!
只看楼主 加入收藏
george_vcool
Rank: 2
等 级:新手上路
威 望:3
帖 子:453
专家分:0
注 册:2007-7-23
结帖率:100%
收藏
 问题点数:0 回复次数:1 
关于windowListener的windowClosed()的方法调用!!

我写了一个程序:
import java.awt.*;
import java.awt.event.*;
class W implements WindowListener{
Frame f;
Button b;
public static void main(String[] args){
W w=new W();
}
W(){
f=new Frame("george");
b=new Button("run");
f.addWindowListener(this);
f.setVisible(true);
}

public void windowClosing(WindowEvent e){
System.out.println("windowclosing");

}
public void windowOpened(WindowEvent e){
System.out.println("windowopened");
}
public void windowIconified(WindowEvent e){
System.out.println("windowIconified");
}
public void windowDeiconified(WindowEvent e){
System.out.println("windowDeiconified");
}
public void windowClosed(WindowEvent e){
System.out.println("windowclosed");
}
public void windowActivated(WindowEvent e){
System.out.println("windowActivated");
}
public void windowDeactivated(WindowEvent e){
System.out.println("windowdeactivated");
}
}
执行程序时,我点击窗口的关闭按钮,只输出windowclosing,我怎么弄才能调用windowclosed()方法
请教了!!

搜索更多相关主题的帖子: windowClosed 
2007-07-30 23:14
jdk2006
Rank: 1
等 级:新手上路
帖 子:244
专家分:0
注 册:2007-5-12
收藏
得分:0 
回复:(george_vcool)关于windowListener的windowCl...

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class W implements WindowListener{
JFrame f;
JButton b;
public static void main(String[] args){
W w=new W();
}
W(){
f=new JFrame("george");
f.dispose();//调用 dispose ()方法来释放资源
f.addWindowListener(this);
f.setVisible(true);
}
public void windowOpened(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowClosing(WindowEvent e){
System.out.println("windowclosing");

}
public void windowClosed(WindowEvent e){//因对窗口调用 dispose 而将其关闭时调用。
System.out.println("windowclosed");
}
}


2007-07-30 23:47
快速回复:关于windowListener的windowClosed()的方法调用!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019604 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved