Simple KeyListener not working

白昼怎懂夜的黑 提交于 2019-12-02 11:35:06

A JPanel cannot gain focus for KeyListener to work.

The preferred approach is to use Key Bindings for Swing. You can map an Action to a KeyStroke even when a component doesn't have focus.

Key Binding Example

I had similar problem but its so simple to solve but you have to found how to solve it witch is not so easy task :D

so how to solve this ? I just set all my buttons as focusable false. instanceOfYourButton.setFocusable(false); thats it

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