You can close the attribute dialog with the ESC key.

This commit is contained in:
hneemann 2017-03-04 16:50:46 +01:00
parent c2fd3c65b5
commit ed51e971fa

View File

@ -83,27 +83,23 @@ public class AttributeDialog extends JDialog {
}
});
JButton cancelButton = new JButton(new AbstractAction(Lang.get("cancel")) {
final AbstractAction cancel = new AbstractAction(Lang.get("cancel")) {
@Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
};
buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.add(cancelButton);
buttonPanel.add(new JButton(cancel));
buttonPanel.add(okButton);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
getRootPane().setDefaultButton(okButton);
getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESC_ACTION_KEY);
getRootPane().getActionMap().put(ESC_ACTION_KEY, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
dispose();
}
});
getRootPane().registerKeyboardAction(cancel,
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
}
/**