How can I listen for key presses (within Java Swing) across all components?

前端 未结 3 1789
傲寒
傲寒 2020-11-28 08:31

I would like to listen for key combinations such as Control+S without adding key listeners to each component in my Swing application. How can I achieve

3条回答
  •  一个人的身影
    2020-11-28 09:14

    I don't think there is a way to add a "global" key listener like you are wanting to do. This forum post with a similar question backs me up. You are just going to have to add them to each component. This should only need to be done once though, so I guess you can just get it over with and move on.

提交回复
热议问题