< prev index next >
src/java.desktop/share/classes/javax/swing/KeyStroke.java
Print this page
*** 41,61 ****
* of trapping every keystroke and throwing away the ones you are not
* interested in, those keystrokes you care about automatically initiate
* actions on the Components with which they are registered.
* <p>
* KeyStrokes are immutable, and are intended to be unique. Client code cannot
! * create a KeyStroke; a variant of <code>getKeyStroke</code> must be used
* instead. These factory methods allow the KeyStroke implementation to cache
* and share instances efficiently.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see javax.swing.text.Keymap
* @see #getKeyStroke
*
--- 41,61 ----
* of trapping every keystroke and throwing away the ones you are not
* interested in, those keystrokes you care about automatically initiate
* actions on the Components with which they are registered.
* <p>
* KeyStrokes are immutable, and are intended to be unique. Client code cannot
! * create a KeyStroke; a variant of {@code getKeyStroke} must be used
* instead. These factory methods allow the KeyStroke implementation to cache
* and share instances efficiently.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see javax.swing.text.Keymap
* @see #getKeyStroke
*
*** 87,98 ****
boolean onKeyRelease) {
super(keyChar, keyCode, modifiers, onKeyRelease);
}
/**
! * Returns a shared instance of a <code>KeyStroke</code>
! * that represents a <code>KEY_TYPED</code> event for the
* specified character.
*
* @param keyChar the character value for a keyboard key
* @return a KeyStroke object for that key
*/
--- 87,98 ----
boolean onKeyRelease) {
super(keyChar, keyCode, modifiers, onKeyRelease);
}
/**
! * Returns a shared instance of a {@code KeyStroke}
! * that represents a {@code KEY_TYPED} event for the
* specified character.
*
* @param keyChar the character value for a keyboard key
* @return a KeyStroke object for that key
*/
*** 107,118 ****
* considered to be activated when it is pressed or released. Unlike all
* other factory methods in this class, the instances returned by this
* method are not necessarily cached or shared.
*
* @param keyChar the character value for a keyboard key
! * @param onKeyRelease <code>true</code> if this KeyStroke corresponds to a
! * key release; <code>false</code> otherwise.
* @return a KeyStroke object for that key
* @deprecated use getKeyStroke(char)
*/
@Deprecated
public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease) {
--- 107,118 ----
* considered to be activated when it is pressed or released. Unlike all
* other factory methods in this class, the instances returned by this
* method are not necessarily cached or shared.
*
* @param keyChar the character value for a keyboard key
! * @param onKeyRelease {@code true} if this KeyStroke corresponds to a
! * key release; {@code false} otherwise.
* @return a KeyStroke object for that key
* @deprecated use getKeyStroke(char)
*/
@Deprecated
public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease) {
*** 123,133 ****
* Returns a shared instance of a {@code KeyStroke}
* that represents a {@code KEY_TYPED} event for the
* specified Character object and a
* set of modifiers. Note that the first parameter is of type Character
* rather than char. This is to avoid inadvertent clashes with calls to
! * <code>getKeyStroke(int keyCode, int modifiers)</code>.
*
* The modifiers consist of any combination of following:<ul>
* <li>java.awt.event.InputEvent.SHIFT_DOWN_MASK
* <li>java.awt.event.InputEvent.CTRL_DOWN_MASK
* <li>java.awt.event.InputEvent.META_DOWN_MASK
--- 123,133 ----
* Returns a shared instance of a {@code KeyStroke}
* that represents a {@code KEY_TYPED} event for the
* specified Character object and a
* set of modifiers. Note that the first parameter is of type Character
* rather than char. This is to avoid inadvertent clashes with calls to
! * {@code getKeyStroke(int keyCode, int modifiers)}.
*
* The modifiers consist of any combination of following:<ul>
* <li>java.awt.event.InputEvent.SHIFT_DOWN_MASK
* <li>java.awt.event.InputEvent.CTRL_DOWN_MASK
* <li>java.awt.event.InputEvent.META_DOWN_MASK
*** 172,182 ****
* <li>java.awt.event.KeyEvent.VK_ENTER
* <li>java.awt.event.KeyEvent.VK_TAB
* <li>java.awt.event.KeyEvent.VK_SPACE
* </ul>
* Alternatively, the key code may be obtained by calling
! * <code>java.awt.event.KeyEvent.getExtendedKeyCodeForChar</code>.
*
* The modifiers consist of any combination of:<ul>
* <li>java.awt.event.InputEvent.SHIFT_DOWN_MASK
* <li>java.awt.event.InputEvent.CTRL_DOWN_MASK
* <li>java.awt.event.InputEvent.META_DOWN_MASK
--- 172,182 ----
* <li>java.awt.event.KeyEvent.VK_ENTER
* <li>java.awt.event.KeyEvent.VK_TAB
* <li>java.awt.event.KeyEvent.VK_SPACE
* </ul>
* Alternatively, the key code may be obtained by calling
! * {@code java.awt.event.KeyEvent.getExtendedKeyCodeForChar}.
*
* The modifiers consist of any combination of:<ul>
* <li>java.awt.event.InputEvent.SHIFT_DOWN_MASK
* <li>java.awt.event.InputEvent.CTRL_DOWN_MASK
* <li>java.awt.event.InputEvent.META_DOWN_MASK
*** 196,207 ****
* them is an integer in which each bit represents a different modifier
* key. Use 0 to specify no modifiers.
*
* @param keyCode an int specifying the numeric code for a keyboard key
* @param modifiers a bitwise-ored combination of any modifiers
! * @param onKeyRelease <code>true</code> if the KeyStroke should represent
! * a key release; <code>false</code> otherwise.
* @return a KeyStroke object for that key
*
* @see java.awt.event.KeyEvent
* @see java.awt.event.InputEvent
*/
--- 196,207 ----
* them is an integer in which each bit represents a different modifier
* key. Use 0 to specify no modifiers.
*
* @param keyCode an int specifying the numeric code for a keyboard key
* @param modifiers a bitwise-ored combination of any modifiers
! * @param onKeyRelease {@code true} if the KeyStroke should represent
! * a key release; {@code false} otherwise.
* @return a KeyStroke object for that key
*
* @see java.awt.event.KeyEvent
* @see java.awt.event.InputEvent
*/
*** 222,232 ****
* <li>java.awt.event.KeyEvent.VK_ENTER
* <li>java.awt.event.KeyEvent.VK_TAB
* <li>java.awt.event.KeyEvent.VK_SPACE
* </ul>
* Alternatively, the key code may be obtained by calling
! * <code>java.awt.event.KeyEvent.getExtendedKeyCodeForChar</code>.
*
* The modifiers consist of any combination of:<ul>
* <li>java.awt.event.InputEvent.SHIFT_DOWN_MASK
* <li>java.awt.event.InputEvent.CTRL_DOWN_MASK
* <li>java.awt.event.InputEvent.META_DOWN_MASK
--- 222,232 ----
* <li>java.awt.event.KeyEvent.VK_ENTER
* <li>java.awt.event.KeyEvent.VK_TAB
* <li>java.awt.event.KeyEvent.VK_SPACE
* </ul>
* Alternatively, the key code may be obtained by calling
! * {@code java.awt.event.KeyEvent.getExtendedKeyCodeForChar}.
*
* The modifiers consist of any combination of:<ul>
* <li>java.awt.event.InputEvent.SHIFT_DOWN_MASK
* <li>java.awt.event.InputEvent.CTRL_DOWN_MASK
* <li>java.awt.event.InputEvent.META_DOWN_MASK
*** 266,286 ****
* This method obtains the keyChar from a KeyTyped event, and the keyCode
* from a KeyPressed or KeyReleased event. The KeyEvent modifiers are
* obtained for all three types of KeyEvent.
*
* @param anEvent the KeyEvent from which to obtain the KeyStroke
! * @throws NullPointerException if <code>anEvent</code> is null
* @return the KeyStroke that precipitated the event
*/
public static KeyStroke getKeyStrokeForEvent(KeyEvent anEvent) {
synchronized (AWTKeyStroke.class) {
return (KeyStroke)getAWTKeyStrokeForEvent(anEvent);
}
}
/**
! * Parses a string and returns a <code>KeyStroke</code>.
* The string must have the following syntax:
* <pre>
* <modifiers>* (<typedID> | <pressedReleasedID>)
*
* modifiers := shift | control | ctrl | meta | alt | altGraph
--- 266,286 ----
* This method obtains the keyChar from a KeyTyped event, and the keyCode
* from a KeyPressed or KeyReleased event. The KeyEvent modifiers are
* obtained for all three types of KeyEvent.
*
* @param anEvent the KeyEvent from which to obtain the KeyStroke
! * @throws NullPointerException if {@code anEvent} is null
* @return the KeyStroke that precipitated the event
*/
public static KeyStroke getKeyStrokeForEvent(KeyEvent anEvent) {
synchronized (AWTKeyStroke.class) {
return (KeyStroke)getAWTKeyStrokeForEvent(anEvent);
}
}
/**
! * Parses a string and returns a {@code KeyStroke}.
* The string must have the following syntax:
* <pre>
* <modifiers>* (<typedID> | <pressedReleasedID>)
*
* modifiers := shift | control | ctrl | meta | alt | altGraph
< prev index next >