Chinaunix首页 | 论坛 | 博客

OS

  • 博客访问: 2212403
  • 博文数量: 691
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2660
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-05 12:49
个人简介

不浮躁

文章分类

全部博文(691)

文章存档

2019年(1)

2017年(12)

2016年(99)

2015年(207)

2014年(372)

分类: Android平台

2015-11-22 15:21:57

上代码:
package exit;

import java.awt.Button;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class exit {
 Frame f = new Frame("test");
 Button b1 = new Button("btn1");
 public void init()
 {
  f.setLayout(null);
  b1.setBounds(20,30,90,29);
  b1.addActionListener(new ActionListener() {
   
   public void actionPerformed(ActionEvent arg0) {
    // TODO Auto-generated method stub
    System.exit(0);
   }
  });
  f.add(b1);
  f.setBounds(50,50,550,500);
  f.setVisible(true);
  
 }

    public static void main(String[] args) {
     new exit().init();
 }
}
直接运行点击就可以退出。
阅读(878) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~