简体   繁体   English

如何将KeyListener添加到整个项目?

[英]How do I add a KeyListener to an entire project?

I am developing an app that requires multiple JFrames. 我正在开发一个需要多个JFrame的应用程序。 The JFrame writes to a file, then is disposed. JFrame写入文件,然后处置。 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. 我想让KeyListener在整个项目中侦听相同的按键,而不必在每个类中创建KeyListener。 Is there a way? 有办法吗?

我同意应该使用键绑定 ,但是由于我无法删除接受的答案,因此必须将其保留在此处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM