Java Swing表单的热键创建 [英] Hotkeys creation for java swing form
问题描述
如何为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屋!