如何在打开新JFrame时禁用主JFrame [英] How to disable main JFrame when open new JFrame

查看:242
本文介绍了如何在打开新JFrame时禁用主JFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在示例我有一个包含jtable的主框架显示所有客户信息,并且有一个创建按钮可以打开一个允许用户创建新客户的新JFrame。我不希望用户可以打开多个创建框架。任何swing组件或API都可以做到这一点?或者如何禁用主框架?像JDialog这样的东西。

Example now I have a main frame contains jtable display all the customer information, and there was a create button to open up a new JFrame that allow user to create new customer. I don't want the user can open more than one create frame. Any swing component or API can do that? or how can disabled the main frame? Something like JDialog.

推荐答案

我建议您将新客户对话框设为模态 JDialog 以便在应用程序可见时,不允许来自应用程序中其他对话框/框架的输入。有关详细信息,请查看模态教程

I would suggest that you make your new customer dialog a modal JDialog so that you do not allow input from other dialogs/frames in your app while it is visible. Take a look at the modality tutorial for details.

这篇关于如何在打开新JFrame时禁用主JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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