addKeyListener() doesn't work for JPanel

后端 未结 2 1668
小蘑菇
小蘑菇 2020-11-27 19:08

I am trying to make a game engine. I have made the Game class but the error resides in the KeyBoard class. Here I leave some code.

Class:: Game



        
2条回答
  •  一个人的身影
    2020-11-27 19:58

    You can add the key listener to the JFrame, that's something I've done in the past. It's probably not a good idea however if you have other components in the JFrame.

提交回复
热议问题