By default, when the user closes a frame onscreen, the frame is hidden. Although invisible, the frame still exists and the program can make it visible again. If you want different behavior, then you need to either register a window listener that handles window-closing events, or you need to specify default close behavior using the setDefaultCloseOperation method. You can even do both.
The argument to setDefaultCloseOperation must be one of the following values, the first three of which are defined in the WindowConstants interface (implemented by JFrame, JInternalPane, and JDialog):
DO_NOTHING_ON_CLOSE
Do not do anything when the user requests that the window close. Instead, the program should probably use a window listener that performs some other action in its windowClosing method.
HIDE_ON_CLOSE (the default for JDialog and JFrame)
Hide the window when the user closes it. This removes the window from the screen but leaves it displayable.
DISPOSE_ON_CLOSE (the default for JInternalFrame)
Hide and dispose of the window when the user closes it. This removes the window from the screen and frees up any resources used by it.
EXIT_ON_CLOSE (defined in the JFrame class)
Exit the application, using System.exit(0). This is recommended for applications only. If used within an applet, a SecurityException may be thrown.
--------------------------------------------------------------------------------
Note: DISPOSE_ON_CLOSE can have results similar to EXIT_ON_CLOSE if only one window is onscreen. More precisely, when the last displayable window within the Java virtual machine (VM) is disposed of, the VM may terminate. See AWT Threading Issues for details.
--------------------------------------------------------------------------------
The default close operation is executed after any window listeners handle the window-closing event. So, for example, assume that you specify that the default close operation is to dispose of a frame. You also implement a window listener that tests whether the frame is the last one visible and, if so, saves some data and exits the application. Under these conditions, when the user closes a frame, the window listener will be called first. If it does not exit the application, then the default close operation — disposing of the frame — will then be performed.
For more information about handling window-closing events, see How to Write Window Listeners. Besides handling window-closing events, window listeners can also react to other window state changes, such as iconification and activation.
The argument to setDefaultCloseOperation must be one of the following values, the first three of which are defined in the WindowConstants interface (implemented by JFrame, JInternalPane, and JDialog):
DO_NOTHING_ON_CLOSE
Do not do anything when the user requests that the window close. Instead, the program should probably use a window listener that performs some other action in its windowClosing method.
HIDE_ON_CLOSE (the default for JDialog and JFrame)
Hide the window when the user closes it. This removes the window from the screen but leaves it displayable.
DISPOSE_ON_CLOSE (the default for JInternalFrame)
Hide and dispose of the window when the user closes it. This removes the window from the screen and frees up any resources used by it.
EXIT_ON_CLOSE (defined in the JFrame class)
Exit the application, using System.exit(0). This is recommended for applications only. If used within an applet, a SecurityException may be thrown.
--------------------------------------------------------------------------------
Note: DISPOSE_ON_CLOSE can have results similar to EXIT_ON_CLOSE if only one window is onscreen. More precisely, when the last displayable window within the Java virtual machine (VM) is disposed of, the VM may terminate. See AWT Threading Issues for details.
--------------------------------------------------------------------------------
The default close operation is executed after any window listeners handle the window-closing event. So, for example, assume that you specify that the default close operation is to dispose of a frame. You also implement a window listener that tests whether the frame is the last one visible and, if so, saves some data and exits the application. Under these conditions, when the user closes a frame, the window listener will be called first. If it does not exit the application, then the default close operation — disposing of the frame — will then be performed.
For more information about handling window-closing events, see How to Write Window Listeners. Besides handling window-closing events, window listeners can also react to other window state changes, such as iconification and activation.
发表评论
-
java.lang.UnsatisfiedLinkError: no j3dcore-ogl-chk in java.library.path
2011-08-19 17:01 2504Exception in thread "main& ... -
打jar包
2011-05-26 18:35 1028打成jar包: 1、没有其他类库jar文件和插件 ... -
Java实现通用线程池
2011-05-05 23:11 1050线程池通俗的描述就是预先创建若干空闲线程,等到需要用多线程去处 ... -
Java tutorial
2011-05-05 21:49 1017http://download.oracle.com/java ... -
java.awt.component.repaint()
2011-05-05 18:57 1039repaint public void repaint()R ... -
validate
2011-05-05 17:21 746validate public void validate( ... -
Class.forName和New的比较
2011-04-26 14:46 708在初始化一个类,生成一个实例的时候,newInstance() ... -
Map、Collection、List接口的总结
2011-04-26 02:52 843Map接口: | + -- ... -
复杂的GridBagLayout
2011-02-07 16:06 1041今天终于耐着性子弄懂了GridBagLayout是怎么使用的。 ... -
swing中的布局管理器
2011-02-07 15:42 14464.CardLayout CardL ... -
swing中的最上层组件
2011-02-07 15:05 2748swing中几乎所有组件都是从JComponent衍生而来,也 ... -
Java swing 组件分层介绍:JRootPane,GlassPane,LayeredPane
2011-02-06 17:01 3052什么是Swing,什么又是ligh ... -
JTextArea操作
2011-01-11 18:03 1242JTextArea操作: (1)在JTextArea插入 ... -
double到int转换
2010-12-16 23:28 848double到int转换,有“截断”误差的。 可以通过+0.5 ... -
各种排序算法java实现
2010-11-25 15:20 595package org.rut.util.algorith ... -
Java中使用BigDecimal进行浮点数高精度计算
2010-11-25 15:18 808转自:http://chongtianpig.netbei.c ... -
利用java内存映射文件机制实现CRC循环冗余校验
2010-11-19 13:52 1097import java.nio.MappedByteBuf ... -
java中进行二进制,八进制,十六进制,十进制间进行相互转换
2010-11-19 13:48 649十进制转成十六进制: Integer.toHexString ... -
JScrollPane 例解
2010-11-19 01:49 1533类层次结构图: java.lang.Object -- ... -
JTextField JTextArea 区分
2010-11-19 01:14 1517一、单行文本输入框(JTextField) 在许多情况下 ...
相关推荐
在学术出版的过程中,回应审稿人的评论是一项重要而复杂的任务,这对于作者来说既是挑战也是机会。本文将详细探讨如何高效地响应审稿人评论,确保论文顺利通过审稿并最终发表。文章主要从十个方面提供应对策略,帮助...
- JavaScript Events And Responding To The User - JavaScript Profiling With The Chrome Developer Tools - Writing Fast, Memory-Efficient JavaScript - Designing Better JavaScript APIs
MTK 内部资料介绍ANR 相关 Outline ▪ What is ANR; ▪ ANR key info; ▪ Analyze ANR; ▪ Example; ▪ Need MTK help; ▪ Monkey ANR
* 1.3.2: Fix windows not responding and focus-follows-mouse choosing the wrong window, add an option to open windows as master * 1.3.3: Fix movement losing windows, add workaround for steam update ...
这篇论文探讨了人工智能领域中自然语言处理的新方法——神经响应机(Neural Responding Machine, NRM),它是一种基于神经网络的响应生成器,专为短文本对话设计。NRM采用了一般编码-解码框架,将响应生成过程形式...
Oracle Incident Response and Forensics Preparing for and Responding to Data Breaches 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自...
Oracle Incident Response and Forensics Preparing for and Responding to Data Breaches 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
if the test was run a couple of times (without closing BurnInTest). Release 5.3 build 1021 WIN32 release 5 June 2008 - 32-bit BurnInTest PRO 5.3.1020 would not start on Windows 2000. This has been ...
仅发送主机名的示例:-“ https://duckduckgo.com/?q=privacy”->“ duckduckgo.com”-“ https://www.openrightsgroup.org/blog/2015/responding-to -无需隐藏-无需担心“->” www.openrightsgroup.org“ --- Icons...
在我遇到问题 info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find a connected Android device.)",...
在使用Loadrunner进行性能测试时,用户可能会遇到“Loadrunner连接负载机失败”的情况,具体表现为:尝试连接负载机时出现错误提示“Failed to connect to load generator. Check the output window for more ...
The molecular genetics of chemotaxis: sensing and responding to chemoattractant gradients The molecular genetics of chemotaxis: sensing and responding to chemoattractant gradients Richard A. Firtel*...
This is the global socket data structure used for responding to the Out-of-the-blue (OOTB) packets. A control sock will be created for this socket at the initialization time.
android开发时常会碰到adb not responding,导致无法调试运行应用程序,通过DDMS的Reset adb后依旧无法解决,那么可以尝试使用此bat文件: 1、下载后点击运行,显示端口使用列表 2、找到状态为LISTENING的一行,复制...
Sensing and responding to events Robots, flying vehicles, Twitter machines, LCD displays, and more! Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning ...
responding class centres in the Euclidean space to achieve intra-class compactness. SphereFace assumes that the lin- ear transformation matrix in the last fully connected layer can be used as a ...
Lambda designed to run code pieces responding to external or internal cloud events, without needing to set up any infrastructure upfront, and it brought a real, managed, and pay-per-go infrastructure...
Besides that I can see my board responding to remote l2ping, hcitool name, hcitool scan and possibly more. To observe app main function, connect rfcomm port (sudo rfcomm |bind> 0 <bdaddr> 1), start ...
Battery Selector must be capable of responding to these events without compromising the integrity of the system’s power supply. Additionally, the selector should notify the system’s power ...