this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
exitedMenuItemActionPerformed(null);
}
});
不关闭就不要exit
public void windowClosing(WindowEvent evt) {
exitedMenuItemActionPerformed(null);
}
});
不关闭就不要exit
解决方案 »
- GUI编程学习第一弹:《计算器》。尽量面相对象,但依然不给力。仍旧全文注释,大家一起勉励
- 纠结啊,关于TextField对象支持监听和处理事件的问题
- 有谁有SCJP1.5的考纲吗?我只是想知道I/O要不要考。
- 创建了几个对象
- 如何将byte[]类型的数据赋值给RSAPrivateKey?
- java本地化gcj编译器安装不成功,望高手指点。
- 类的方法调用 反射相关
- DefaultMutableTreeNode 中的add method的实际意思?
- 如何从servlet中获得请求该servlet的jsp页面的url?
- 帮帮我
- 晕了,昨天我的分还多些,怎么今天还少了?是什么问题??
- 如何更改程序外观阿?分给的多
public void setExtendedState(int state)
Sets the state of this frame. The state is represented as a bitwise mask.
NORMAL
Indicates that no state bits are set.
ICONIFIED
MAXIMIZED_HORIZ
MAXIMIZED_VERT
MAXIMIZED_BOTH
Concatenates MAXIMIZED_HORIZ and MAXIMIZED_VERT.
Note that if the state is not supported on a given platform, nothing will happen. The application may determine if a specific state is available via the java.awt.Toolkit#isFrameStateSupported(int state) method.
Parameters:
state - a bitwise mask of frame state constants
Since:
1.4
public void setDefaultCloseOperation(int operation)
Sets the operation that will happen by default when the user initiates a "close" on this frame. You must specify one of the following choices: DO_NOTHING_ON_CLOSE (defined in WindowConstants): Don't do anything; require the program to handle the operation in the windowClosing method of a registered WindowListener object.
HIDE_ON_CLOSE (defined in WindowConstants): Automatically hide the frame after invoking any registered WindowListener objects.
DISPOSE_ON_CLOSE (defined in WindowConstants): Automatically hide and dispose the frame after invoking any registered WindowListener objects.
EXIT_ON_CLOSE (defined in JFrame): Exit the application using the System exit method. Use this only in applications.
The value is set to HIDE_ON_CLOSE by default. Note: When the last displayable window within the Java virtual machine (VM) is disposed of, the VM may terminate. See AWT Threading Issues for more information.
Parameters:
operation - the operation which should be performed when the user closes the frame
Throws:
IllegalArgumentException - if defaultCloseOperation value isn't one of the above valid values
SecurityException - if EXIT_ON_CLOSE has been specified and the SecurityManager will not allow the caller to invoke System.exit
{
public void windowClosing( WindowEvent e )
{
//to do here
}
} );
{
public void windowClosing( WindowEvent e )
{
int n = JOptionPane.showConfirmDialog( this,
"确认退出",
"something",
JOptionPane.YES_NO_OPTION ); if ( n == JOptionPane.YES_OPTION )
{
System.exit( 0 );
}
}
} );
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);把它去掉咯~~
JFrame.EXIT_ON_CLOSE这个常量是关闭的,还有个不关闭的想不起来了,如果不写还是可以关闭的
所以要写
不知道这个方法可以不?