mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-30 08:23:37 -04:00
You can close the attribute dialog with the ESC key.
This commit is contained in:
parent
c2fd3c65b5
commit
ed51e971fa
@ -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
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
|
||||||
buttonPanel.add(cancelButton);
|
buttonPanel.add(new JButton(cancel));
|
||||||
buttonPanel.add(okButton);
|
buttonPanel.add(okButton);
|
||||||
|
|
||||||
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
|
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
getRootPane().setDefaultButton(okButton);
|
getRootPane().setDefaultButton(okButton);
|
||||||
getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESC_ACTION_KEY);
|
getRootPane().registerKeyboardAction(cancel,
|
||||||
getRootPane().getActionMap().put(ESC_ACTION_KEY, new AbstractAction() {
|
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
|
||||||
@Override
|
JComponent.WHEN_IN_FOCUSED_WINDOW);
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user