标题:大家帮帮我啊,窗口无法关闭
取消只看楼主
bizika526
Rank: 1
等 级:新手上路
帖 子:45
专家分:0
注 册:2007-10-20
 问题点数:0 回复次数:0 
大家帮帮我啊,窗口无法关闭
import java.awt.*;
import java.awt.event.*;
class TestFrame{
    public static void main(String[] args){
        
        Frame f=new Frame("IT人资迅交流网");
        //f.add(new Button("oK"));
        f.add(new Button("确定"));
        f.setSize(300,300);
        f.setVisible(true);
    }
}

//为窗口添加关闭功能
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){}
}
我用的是JCreator Pro,这是书上例子,但是无法关闭窗口,请大虾们修改一下,并简要说明一下原因,谢谢
搜索更多相关主题的帖子: 窗口 void awt public 
2007-12-11 22:24



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-191942-1-1.html




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

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