如何将 KeyListener 添加到整个项目?
我正在开发一个需要多个 JFrame 的应用程序。 JFrame 写入文件,然后被释放。我希望有一个 KeyListener 在整个项目中监听相同的按键,而不必在每个类中创建 KeyListener。有办法吗?
I am developing an app that requires multiple JFrames. The JFrame writes to a file, then is disposed. I want to have a KeyListener listen for the same key press, throughout the entire project without having to create the KeyListener in each class. Is there a way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我同意应该使用键绑定,但是因为我可以不要删除我接受的答案,我必须把它留在这里。
I agree that key bindings should be used, but since I can't delete my accepted answer I have to leave this here.