这两种方法有什么区别:
getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(
"pressed F10"), "someAction");
getActionMap().put("someAction", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
//Do something
}
});
和:
registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//Do something
}
}, KeyStroke.getKeyStroke("pressed F10"), JComponent.WHEN_FOCUSED);