How to disable main JFrame when open new JFrame(打开新 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
,这样您就不允许其他对话框/框架输入您的应用程序可见时.查看modality 教程了解详情.
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:打开新 JFrame 时如何禁用主 JFrame


基础教程推荐
- 在螺旋中写一个字符串 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01