Java Swing表单的热键创建 [英] Hotkeys creation for java swing form

查看:184
本文介绍了Java Swing表单的热键创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为Java swing创建的表单创建热键?例如,为学生详细信息创建表单意味着如果我按ALT + N表示光标将转到该名称输入字段.ALT + R表示光标将转到Reg.no而不输入Field.类似于mark1(m1),mark(2)等.同时,该表单包含保存,如果按CTRL + S,则退出按钮,意味着将选择Save.CTRL + X意味着退出按钮将会选择.如何执行此操作?

How to Create hot keys for form which is made by java swing?for example the form is create for student details means if I press ALT+N means the cursor will goto that name entering field.ALT+R means the cursor will goto Reg.no entering Field.same like as mark1(m1),mark(2) and so on.At that same time the form contains save,exit buttons if I press CTRL+S means the Save button will select.CTRL+X means the exit button will select.how to do this?

推荐答案

请参见如何使用键绑定,然后将该知识与

See How to Use Key Bindings, then use that knowledge in conjunction with requestFocusInWindow().

CTRL + X表示将选择退出按钮.

CTRL+X means the exit button will select.

另请参见 用于按钮,并 setAccelerator(KeyStroke) 用于菜单项.或更一般而言,使用 Action 具有已配置的值.

See also setMnemonic(char) for buttons and setAccelerator(KeyStroke) for menu items. Or more generally, constructing those controls using an Action that has the values configured.

这篇关于Java Swing表单的热键创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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