JFrame表单上的JDialog操作 [英] JDialog actions on JFrame form

查看:183
本文介绍了JFrame表单上的JDialog操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用命令按钮yes和no实例化已设计的jdialog的新对象,我在JFrame表单的windowClosing事件上实现了新对象,但我不知道如何执行诸如关闭之类的操作如果单击按钮是,则单击该表单,或者如果单击按钮否,则表示不执行任何操作。

您可以通过我吗?



[HB编辑:删除粗体和大字体]

I instantiate a new object of an already designed jdialog with command buttons "yes" and "no", I implemented the new object on the windowClosing event of a JFrame form but I dont know how to carry out an operation such as closing the form if the button "yes" is been clicked or the not doing any thing if button "no" is been clicked.
Can you put me through please?

[HB removed bold and large font]

推荐答案

if(yes){
   frameObj.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}else{
   frameObj.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
}


我将两个按钮公开,然后在点击按钮时随时更改布尔值。同时,构造函数中的Boolean为false。因此,我可以在采取行动之前检查布尔变量的值。
I make the two buttons public and then I make a Boolean to change anytime the button is clicked. Meanwhile the Boolean is false inside the constructor. Therefore I can check the value of the Boolean variable before taking actions.


这篇关于JFrame表单上的JDialog操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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