KeyListeners vs Keybindings? [duplicate]

混江龙づ霸主 提交于 2019-12-02 02:57:06

The Keylistener is an older interface from the AWT days, its still Ok to use it with swing but is more of a general listener. It binds to all keys.

KeyBindings are a bit different in that they specifically bind a specific action to a specific key and other keys remain unaffected. The upshot of this is if you are going to listen for any key then a KeyListener is appropriate or you will have to implement seperate KeyBindings all for all keys which is patently silly.

To avoid event handlers with big switch statements the KeyBinding exists.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!