在Swing中,如何在没有特定组件的情况下应用KeyListener [英] In Swing, how to apply KeyListener on no specific component

查看:52
本文介绍了在Swing中,如何在没有特定组件的情况下应用KeyListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我们将密钥侦听器应用于特定的组件,例如文本字段,密码字段等.但是我想对此侦听器行为进行概括,以适用于所有人.

Generally we apply the Key Listener on specific components like text field, password fields, etc. But I would like to generalize this listener behavior to be applicable to all.

推荐答案

Swing旨在与可能会执行您想要的操作的键绑定一起使用.我将从签出键绑定开始.不要忘记阅读Swing教程以获取完整信息.

Swing was designed to be used with Key Bindings which might do what you want. I would start by checking out Key Bindings. Don't forget to read the Swing tutorial for complete information.

如果这样做没有帮助,请参见全局事件监听器提出一些建议.

If that doesn't help then see Global Event Listeners for a couple of suggestions.

这篇关于在Swing中,如何在没有特定组件的情况下应用KeyListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆