| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 407 人关注过本帖
标题:实现窗口关闭怎么实现不了?
取消只看楼主 加入收藏
左手拉拉
Rank: 1
等 级:新手上路
帖 子:40
专家分:2
注 册:2012-3-3
结帖率:80%
收藏
已结贴  问题点数:20 回复次数:0 
实现窗口关闭怎么实现不了?
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
        
    }

   
 
   
        
   
   

   

}
搜索更多相关主题的帖子: super package public import close 
2012-05-21 19:01
快速回复:实现窗口关闭怎么实现不了?
数据加载中...
 
   



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

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