jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(86, java.awt.event.KeyEvent.CTRL_MASK, true));

解决方案 »

  1.   

    getKeyStroke 
    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
    See Also: KeyEvent, Event