How to disable default JDialog button for ENTER key in component

I am trying to embed webrenderer (Swing web browser) in JDialog, which has a default button. Returning to any form text field inside the loaded HTML causes the default JDialog button to start and close the dialog.

Due to the nature of the application, I cannot simply not use the default button in the dialog box, since it is a dynamically built general dialog class used in several places.

I need to somehow disable the processing / events of the buttons by default (I think in much the same way as the other JTextComponents). This does not help webrenderer, which is a third-party tool, and I do not have access to the source code.

Thanks Rob.

+4
source share
1 answer
jdialog.getRootPane().setDefaultButton(null); 

reference: javax.swing.JRootPane :: setDefaultButton (JButton)

+5
source

All Articles