不使用close(X)按钮关闭我的jframe并终止JVM [英] closing my jframe without using the close(X) button and terminating the JVM

查看:54
本文介绍了不使用close(X)按钮关闭我的jframe并终止JVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实例化另一个框架的框架,但是我不想在实例化的框架上使用close(x)按钮.所以我创建了一个按钮.我如何编码该按钮可用于关闭实例化的框架而不退出JVM.

i have a frame that instantiates another frame but i don't want to use the close(x) button on the instantiated frame., so i created a button. how do i code that this button can be used to close the instantiated frame without quitting the JVM.

推荐答案

拥有自己的关闭按钮是怪异的UI,应避免使用.

Having your own close button is weird UI and should be avoided.

要在单击您自己的按钮时摆脱一帧,您可以执行以下操作:

To get rid of a frame when your own button is clicked you can just do:

jFrame.setVisible(false);

jFrame.dispose();

如果您想完全摆脱它.

对于不想在单击关闭按钮时退出JVM的框架,请指定:

On frames you don't want to exit the JVM on the close button being clicked specify:

jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

jFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

取决于您想要的行为.

这篇关于不使用close(X)按钮关闭我的jframe并终止JVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆