How to make two JPanels listen to the same event?

后端 未结 4 1635
你的背包
你的背包 2020-12-17 05:56

I have a JFrame and, inside this JFrame there are two JPanels. When I press a key, both of them must listen to this key event and act.

4条回答
  •  旧巷少年郎
    2020-12-17 06:16

    You should create a XXListener implementation and add that listener by .addXXListener to all the components you need.

提交回复
热议问题