键盘快捷键和动作监听器
想知道如何将键盘键链接到netbeans中的JButton,从oracle下载了KeyEventDemo程序,它可以让你按下一个键,它会告诉你键码,现在我想知道如何实现它,在一个计算器项目上工作,我已经有能力单击任何按钮并使其为 +、-、/、*或 enter 所以现在我想知道如何将两者链接在一起,本质上我想弄清楚如何检查方法中按下了哪个键,然后根据它们的内容运行一个方法压!感谢您提供任何信息!
Wondering how to link a keyboard key to a JButton in netbeans, Downloaded KeyEventDemo program from oracle that lets you press a key and it tells you the keycode, Now im wondering how to implement that, working on a calculator project and I already have the ability to click on any button and have it either +,-,/,* or enter so now I am wondering how to link the 2 together, essentially I'm trying to figure out how to check which key is being pressed in a method, and then run a method depending on what they pressed! thanks for any info!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅如何使用键绑定。基本上,您将 KeyStroke 绑定到 Action。本教程还有一个关于如何使用操作的部分。
See How to Use Key Bindings. Basically you bind a KeyStroke to an Action. The tutorial also has a section on How to Use Actions.