a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 62|回复: 0

[综合辅导] 关闭Java窗体的技巧1

[复制链接]
发表于 2012-8-4 12:07:07 | 显示全部楼层 |阅读模式
使用JFrame的enableEvents和processWindowEvent
& d5 Z8 O' Z3 p& B) L9 t' y& S# e. F, z5 v1 O' e. @% \
  //Frame1.java  import java.awt.*;  import java.awt.event.*;  import javax.swing.*;  public class Frame1 extends JFrame {  public Frame1() {  enableEvents(AWTEvent.WINDOW_EVENT_MASK);  this.setSize(new Dimension(400, 300));  this.setTitle("Frame1");  }  protected void processWindowEvent(WindowEvent e) {  super.processWindowEvent(e);  if (e.getID() == WindowEvent.WINDOW_CLOSING) {  System.exit(0);  }  }  
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-18 02:24 , Processed in 0.233599 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表