jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(86, java.awt.event.KeyEvent.CTRL_MASK, true));
解决方案 »
- 关于string类的问题
- 日历的刷新显示问题
- 请问java哪些类实现线程?
- 求一个Select语句:如何实现MySQl的递归查询
- 有两个窗口,b窗口(b类)由a窗口(a类)打开,现在把b窗口关闭后a窗口重新获得焦点,在得到焦点后想先执行一段代码。要怎么触发
- 各位大侠关于文本编辑器jedit安装问题
- weblogic7.0带的ms sql server2000 driver不支持jdbc2.0?
- 大家都用什么开发工具啊?
- String str[][] 如何取到第一部分[]的长度?
- protected关键字
- 谁知道javascript的调试工具!!!--在线等待
- 高手大虾们,在"swing"中如何给菜单项加如快捷键如ctrl v ---先谢了
用setAccelerator设置快捷键吧。
public static KeyStroke getKeyStroke(int keyCode,
int modifiers,
boolean onKeyRelease)
Return a shared instance of a key stroke given a numeric keycode and a set of modifiers, specifying whether the key is activated when it is pressed or released.
The "virtual key" constants defined in java.awt.event.KeyEvent can be used to specify the key code. For example: java.awt.event.KeyEvent.VK_ENTER
java.awt.event.KeyEvent.VK_TAB
java.awt.event.KeyEvent.VK_SPACE
The modifiers consist of any combination of: java.awt.Event.SHIFT_MASK (1)
java.awt.Event.CTRL_MASK (2)
java.awt.Event.META_MASK (4)
java.awt.Event.ALT_MASK (8)
Since these numbers are all different powers of two, any combination of them is an integer in which each bit represents a different modifier key.
Parameters:
keyCode - an int specifying the numeric code for a keyboard keymodifiers - an int specifying any combination of the key modifiers.
onKeyRelease - a boolean value. When true, specifies that the key is active when it is released.
Returns:a KeyStroke object for that key