src/share/classes/java/awt/event/KeyEvent.java

Print this page

        

*** 928,950 **** --- 928,963 ---- public void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode) { ev.extendedKeyCode = extendedKeyCode; } + + public Component getOriginalSource( KeyEvent ev ) { + return ev.originalSource; + } }); } /** * Initialize JNI field and method IDs for fields that may be * accessed from C. */ private static native void initIDs(); + /** + * The original event source. + * + * Event source can be changed during processing, but in some cases + * we need to able to obtain original source. + */ + private Component originalSource; + private KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation, boolean isProxyActive) { this(source, id, when, modifiers, keyCode, keyChar, keyLocation); this.isProxyActive = isProxyActive; + originalSource = source; } /** * Constructs a <code>KeyEvent</code> object. * <p>This method throws an
*** 1021,1030 **** --- 1034,1044 ---- if ((getModifiers() != 0) && (getModifiersEx() == 0)) { setNewModifiers(); } else if ((getModifiers() == 0) && (getModifiersEx() != 0)) { setOldModifiers(); } + originalSource = source; } /** * Constructs a <code>KeyEvent</code> object. * <p> This method throws an
*** 1067,1085 **** --- 1081,1101 ---- */ public KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar) { this(source, id, when, modifiers, keyCode, keyChar, KEY_LOCATION_UNKNOWN); + originalSource = source; } /** * @deprecated as of JDK1.1 */ @Deprecated public KeyEvent(Component source, int id, long when, int modifiers, int keyCode) { this(source, id, when, modifiers, keyCode, (char)keyCode); + originalSource = source; } /** * Returns the integer keyCode associated with the key in this event. *