I have a dialogA which is open on top of another dialogB. Both are subclasses of javax.swing.JDialog. DialogB is set to be the owner of dialogA. Both dialogs have a default button defined using the following code snippet:

JButton changeButton = new JButton("Change");
getRootPane().setDefaultButton(changeButton);
changeButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
hide();
if (owner != null)
{
owner.show();
owner.toFront();
}
}
});

The changeButton works fine if clicked by the mouse. However, if the Enter key is pressed it cascades through both of the dialogs. In other words, when the user hits Enter it invokes the default button of dialogA - which is fine. But it also invokes the default button of the owner dailogB. Is there a way of preventing the Enter key from penetrating through the dialogs?