简体   繁体   English

如何禁用组件中ENTER键的JDialog默认按钮处理

[英]How to disable the JDialog default button handling of ENTER key within a component

I am attempting to embedd webrenderer (a Swing based web browser) within a JDialog that has a default button defined. 我试图在JDialog中嵌入webrenderer(基于Swing的Web浏览器),该JDialog定义了默认按钮。 Hitting return in any of the form textareas within the loaded HTML is causing the JDialog default button to fire and close the dialog. 在加载的HTML中以任何形式textareas命中返回会导致JDialog默认按钮触发并关闭对话框。

Due to the nature of the application I can't simply not use a default button on the dialog as it is a dynamically constructed generic dialog class used in multiple places. 由于应用程序的性质,我不能简单地不使用对话框上的默认按钮,因为它是在多个地方使用的动态构造的通用对话框类。

I need some way to disable the default button handling/events ( I guess in much the same way that other JTextComponents must be doing). 我需要一些方法来禁用默认的按钮处理/事件(我想与其他JTextComponents必须做的事情大致相同)。 This is not helped by webrenderer being a 3rd party tool and I have no access to the source code. webrenderer作为第三方工具并没有帮助,我无法访问源代码。

Thanks Rob. 谢谢Rob。

jdialog.getRootPane().setDefaultButton(null);

参考: javax.swing.JRootPane :: setDefaultButton(JButton)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM