registerKeyboardAction(...)和getInputMap().put(...)+ getActionMap().put(...)之间有什么区别? [英] What is the difference between registerKeyboardAction(...) and getInputMap().put(...) + getActionMap().put(...)?

查看:124
本文介绍了registerKeyboardAction(...)和getInputMap().put(...)+ getActionMap().put(...)之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两种方法有什么区别?

What is the difference between these two methods:

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);

推荐答案

没有区别,但是registerKeyboardAction已过时,如javadoc中所述.

There is no difference, but registerKeyboardAction is obsolete as stated in the javadoc.

这篇关于registerKeyboardAction(...)和getInputMap().put(...)+ getActionMap().put(...)之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆