Home » openjdk-7 » java » awt » event » [javadoc | source]

    1   /*
    2    * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22    * or visit www.oracle.com if you need additional information or have any
   23    * questions.
   24    */
   25   
   26   package java.awt.event;
   27   
   28   import java.awt.Event;
   29   import java.awt.Component;
   30   import java.awt.GraphicsEnvironment;
   31   import java.awt.Toolkit;
   32   import java.io.IOException;
   33   import java.io.ObjectInputStream;
   34   
   35   /**
   36    * An event which indicates that a keystroke occurred in a component.
   37    * <p>
   38    * This low-level event is generated by a component object (such as a text
   39    * field) when a key is pressed, released, or typed.
   40    * The event is passed to every <code>KeyListener</code>
   41    * or <code>KeyAdapter</code> object which registered to receive such
   42    * events using the component's <code>addKeyListener</code> method.
   43    * (<code>KeyAdapter</code> objects implement the
   44    * <code>KeyListener</code> interface.)  Each such listener object
   45    * gets this <code>KeyEvent</code> when the event occurs.
   46    * <p>
   47    * <em>"Key typed" events</em> are higher-level and generally do not depend on
   48    * the platform or keyboard layout.  They are generated when a Unicode character
   49    * is entered, and are the preferred way to find out about character input.
   50    * In the simplest case, a key typed event is produced by a single key press
   51    * (e.g., 'a').  Often, however, characters are produced by series of key
   52    * presses (e.g., 'shift' + 'a'), and the mapping from key pressed events to
   53    * key typed events may be many-to-one or many-to-many.  Key releases are not
   54    * usually necessary to generate a key typed event, but there are some cases
   55    * where the key typed event is not generated until a key is released (e.g.,
   56    * entering ASCII sequences via the Alt-Numpad method in Windows).
   57    * No key typed events are generated for keys that don't generate Unicode
   58    * characters (e.g., action keys, modifier keys, etc.).
   59    * <p>
   60    * The getKeyChar method always returns a valid Unicode character or
   61    * CHAR_UNDEFINED.  Character input is reported by KEY_TYPED events:
   62    * KEY_PRESSED and KEY_RELEASED events are not necessarily associated
   63    * with character input.  Therefore, the result of the getKeyChar method
   64    * is guaranteed to be meaningful only for KEY_TYPED events.
   65    * <p>
   66    * For key pressed and key released events, the getKeyCode method returns
   67    * the event's keyCode.  For key typed events, the getKeyCode method
   68    * always returns {@code VK_UNDEFINED}. The {@code getExtendedKeyCode} method
   69    * may also be used with many international keyboard layouts.
   70    *
   71    * <p>
   72    * <em>"Key pressed" and "key released" events</em> are lower-level and depend
   73    * on the platform and keyboard layout. They are generated whenever a key is
   74    * pressed or released, and are the only way to find out about keys that don't
   75    * generate character input (e.g., action keys, modifier keys, etc.). The key
   76    * being pressed or released is indicated by the {@code getKeyCode} and {@code getExtendedKeyCode}
   77    * methods, which return a virtual key code.
   78    *
   79    * <p>
   80    * <em>Virtual key codes</em> are used to report which keyboard key has
   81    * been pressed, rather than a character generated by the combination
   82    * of one or more keystrokes (such as "A", which comes from shift and "a").
   83    *
   84    * <p>
   85    * For example, pressing the Shift key will cause a KEY_PRESSED event
   86    * with a VK_SHIFT keyCode, while pressing the 'a' key will result in
   87    * a VK_A keyCode.  After the 'a' key is released, a KEY_RELEASED event
   88    * will be fired with VK_A. Separately, a KEY_TYPED event with a keyChar
   89    * value of 'A' is generated.
   90    *
   91    * <p>
   92    * Pressing and releasing a key on the keyboard results in the generating
   93    * the following key events (in order):
   94    * <PRE>
   95    *    {@code KEY_PRESSED}
   96    *    {@code KEY_TYPED} (is only generated if a valid Unicode character could be generated.)
   97    *    {@code KEY_RELEASED}
   98    * </PRE>
   99    *
  100    * But in some cases (e.g. auto-repeat or input method is activated) the order
  101    * could be different (and platform dependent).
  102    *
  103    * <p>
  104    * Notes:
  105    * <ul>
  106    * <li>Key combinations which do not result in Unicode characters, such as action
  107    * keys like F1 and the HELP key, do not generate KEY_TYPED events.
  108    * <li>Not all keyboards or systems are capable of generating all
  109    * virtual key codes.  No attempt is made in Java to generate these keys
  110    * artificially.
  111    * <li>Virtual key codes do not identify a physical key: they depend on the
  112    * platform and keyboard layout. For example, the key that generates VK_Q
  113    * when using a U.S. keyboard layout will generate VK_A when using a French
  114    * keyboard layout.
  115    * <li>The key that generates {@code VK_Q} when using a U.S. keyboard layout also
  116    * generates a unique code for Russian or Hebrew layout. There is no a
  117    * {@code VK_} constant for these and many other codes in various layouts. These codes
  118    * may be obtained by using {@code getExtendedKeyCode} and are used whenever
  119    * a {@code VK_} constant is used.
  120    * <li>Not all characters have a keycode associated with them.  For example,
  121    * there is no keycode for the question mark because there is no keyboard
  122    * for which it appears on the primary layer.
  123    * <li>In order to support the platform-independent handling of action keys,
  124    * the Java platform uses a few additional virtual key constants for functions
  125    * that would otherwise have to be recognized by interpreting virtual key codes
  126    * and modifiers. For example, for Japanese Windows keyboards, VK_ALL_CANDIDATES
  127    * is returned instead of VK_CONVERT with the ALT modifier.
  128    * <li>As specified in <a href="../doc-files/FocusSpec.html">Focus Specification</a>
  129    * key events are dispatched to the focus owner by default.
  130    * </ul>
  131    *
  132    * <p>
  133    * WARNING: Aside from those keys that are defined by the Java language
  134    * (VK_ENTER, VK_BACK_SPACE, and VK_TAB), do not rely on the values of the VK_
  135    * constants.  Sun reserves the right to change these values as needed
  136    * to accomodate a wider range of keyboards in the future.
  137    * <p>
  138    * An unspecified behavior will be caused if the {@code id} parameter
  139    * of any particular {@code KeyEvent} instance is not
  140    * in the range from {@code KEY_FIRST} to {@code KEY_LAST}.
  141    *
  142    * @author Carl Quinn
  143    * @author Amy Fowler
  144    * @author Norbert Lindenberg
  145    *
  146    * @see KeyAdapter
  147    * @see KeyListener
  148    * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/keylistener.html">Tutorial: Writing a Key Listener</a>
  149    *
  150    * @since 1.1
  151    */
  152   public class KeyEvent extends InputEvent {
  153   
  154       /**
  155        * Stores the state of native event dispatching system
  156        * - true, if when the event was created event proxying
  157        *         mechanism was active
  158        * - false, if it was inactive
  159        * Used in Component.dispatchEventImpl to correctly dispatch
  160        * events when proxy is active
  161        */
  162       private boolean isProxyActive = false;
  163   
  164       /**
  165        * The first number in the range of ids used for key events.
  166        */
  167       public static final int KEY_FIRST = 400;
  168   
  169       /**
  170        * The last number in the range of ids used for key events.
  171        */
  172       public static final int KEY_LAST  = 402;
  173   
  174       /**
  175        * The "key typed" event.  This event is generated when a character is
  176        * entered.  In the simplest case, it is produced by a single key press.
  177        * Often, however, characters are produced by series of key presses, and
  178        * the mapping from key pressed events to key typed events may be
  179        * many-to-one or many-to-many.
  180        */
  181       public static final int KEY_TYPED = KEY_FIRST;
  182   
  183       /**
  184        * The "key pressed" event. This event is generated when a key
  185        * is pushed down.
  186        */
  187       public static final int KEY_PRESSED = 1 + KEY_FIRST; //Event.KEY_PRESS
  188   
  189       /**
  190        * The "key released" event. This event is generated when a key
  191        * is let up.
  192        */
  193       public static final int KEY_RELEASED = 2 + KEY_FIRST; //Event.KEY_RELEASE
  194   
  195       /* Virtual key codes. */
  196   
  197       public static final int VK_ENTER          = '\n';
  198       public static final int VK_BACK_SPACE     = '\b';
  199       public static final int VK_TAB            = '\t';
  200       public static final int VK_CANCEL         = 0x03;
  201       public static final int VK_CLEAR          = 0x0C;
  202       public static final int VK_SHIFT          = 0x10;
  203       public static final int VK_CONTROL        = 0x11;
  204       public static final int VK_ALT            = 0x12;
  205       public static final int VK_PAUSE          = 0x13;
  206       public static final int VK_CAPS_LOCK      = 0x14;
  207       public static final int VK_ESCAPE         = 0x1B;
  208       public static final int VK_SPACE          = 0x20;
  209       public static final int VK_PAGE_UP        = 0x21;
  210       public static final int VK_PAGE_DOWN      = 0x22;
  211       public static final int VK_END            = 0x23;
  212       public static final int VK_HOME           = 0x24;
  213   
  214       /**
  215        * Constant for the non-numpad <b>left</b> arrow key.
  216        * @see #VK_KP_LEFT
  217        */
  218       public static final int VK_LEFT           = 0x25;
  219   
  220       /**
  221        * Constant for the non-numpad <b>up</b> arrow key.
  222        * @see #VK_KP_UP
  223        */
  224       public static final int VK_UP             = 0x26;
  225   
  226       /**
  227        * Constant for the non-numpad <b>right</b> arrow key.
  228        * @see #VK_KP_RIGHT
  229        */
  230       public static final int VK_RIGHT          = 0x27;
  231   
  232       /**
  233        * Constant for the non-numpad <b>down</b> arrow key.
  234        * @see #VK_KP_DOWN
  235        */
  236       public static final int VK_DOWN           = 0x28;
  237   
  238       /**
  239        * Constant for the comma key, ","
  240        */
  241       public static final int VK_COMMA          = 0x2C;
  242   
  243       /**
  244        * Constant for the minus key, "-"
  245        * @since 1.2
  246        */
  247       public static final int VK_MINUS          = 0x2D;
  248   
  249       /**
  250        * Constant for the period key, "."
  251        */
  252       public static final int VK_PERIOD         = 0x2E;
  253   
  254       /**
  255        * Constant for the forward slash key, "/"
  256        */
  257       public static final int VK_SLASH          = 0x2F;
  258   
  259       /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
  260       public static final int VK_0              = 0x30;
  261       public static final int VK_1              = 0x31;
  262       public static final int VK_2              = 0x32;
  263       public static final int VK_3              = 0x33;
  264       public static final int VK_4              = 0x34;
  265       public static final int VK_5              = 0x35;
  266       public static final int VK_6              = 0x36;
  267       public static final int VK_7              = 0x37;
  268       public static final int VK_8              = 0x38;
  269       public static final int VK_9              = 0x39;
  270   
  271       /**
  272        * Constant for the semicolon key, ";"
  273        */
  274       public static final int VK_SEMICOLON      = 0x3B;
  275   
  276       /**
  277        * Constant for the equals key, "="
  278        */
  279       public static final int VK_EQUALS         = 0x3D;
  280   
  281       /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
  282       public static final int VK_A              = 0x41;
  283       public static final int VK_B              = 0x42;
  284       public static final int VK_C              = 0x43;
  285       public static final int VK_D              = 0x44;
  286       public static final int VK_E              = 0x45;
  287       public static final int VK_F              = 0x46;
  288       public static final int VK_G              = 0x47;
  289       public static final int VK_H              = 0x48;
  290       public static final int VK_I              = 0x49;
  291       public static final int VK_J              = 0x4A;
  292       public static final int VK_K              = 0x4B;
  293       public static final int VK_L              = 0x4C;
  294       public static final int VK_M              = 0x4D;
  295       public static final int VK_N              = 0x4E;
  296       public static final int VK_O              = 0x4F;
  297       public static final int VK_P              = 0x50;
  298       public static final int VK_Q              = 0x51;
  299       public static final int VK_R              = 0x52;
  300       public static final int VK_S              = 0x53;
  301       public static final int VK_T              = 0x54;
  302       public static final int VK_U              = 0x55;
  303       public static final int VK_V              = 0x56;
  304       public static final int VK_W              = 0x57;
  305       public static final int VK_X              = 0x58;
  306       public static final int VK_Y              = 0x59;
  307       public static final int VK_Z              = 0x5A;
  308   
  309       /**
  310        * Constant for the open bracket key, "["
  311        */
  312       public static final int VK_OPEN_BRACKET   = 0x5B;
  313   
  314       /**
  315        * Constant for the back slash key, "\"
  316        */
  317       public static final int VK_BACK_SLASH     = 0x5C;
  318   
  319       /**
  320        * Constant for the close bracket key, "]"
  321        */
  322       public static final int VK_CLOSE_BRACKET  = 0x5D;
  323   
  324       public static final int VK_NUMPAD0        = 0x60;
  325       public static final int VK_NUMPAD1        = 0x61;
  326       public static final int VK_NUMPAD2        = 0x62;
  327       public static final int VK_NUMPAD3        = 0x63;
  328       public static final int VK_NUMPAD4        = 0x64;
  329       public static final int VK_NUMPAD5        = 0x65;
  330       public static final int VK_NUMPAD6        = 0x66;
  331       public static final int VK_NUMPAD7        = 0x67;
  332       public static final int VK_NUMPAD8        = 0x68;
  333       public static final int VK_NUMPAD9        = 0x69;
  334       public static final int VK_MULTIPLY       = 0x6A;
  335       public static final int VK_ADD            = 0x6B;
  336   
  337       /**
  338        * This constant is obsolete, and is included only for backwards
  339        * compatibility.
  340        * @see #VK_SEPARATOR
  341        */
  342       public static final int VK_SEPARATER      = 0x6C;
  343   
  344       /**
  345        * Constant for the Numpad Separator key.
  346        * @since 1.4
  347        */
  348       public static final int VK_SEPARATOR      = VK_SEPARATER;
  349   
  350       public static final int VK_SUBTRACT       = 0x6D;
  351       public static final int VK_DECIMAL        = 0x6E;
  352       public static final int VK_DIVIDE         = 0x6F;
  353       public static final int VK_DELETE         = 0x7F; /* ASCII DEL */
  354       public static final int VK_NUM_LOCK       = 0x90;
  355       public static final int VK_SCROLL_LOCK    = 0x91;
  356   
  357       /** Constant for the F1 function key. */
  358       public static final int VK_F1             = 0x70;
  359   
  360       /** Constant for the F2 function key. */
  361       public static final int VK_F2             = 0x71;
  362   
  363       /** Constant for the F3 function key. */
  364       public static final int VK_F3             = 0x72;
  365   
  366       /** Constant for the F4 function key. */
  367       public static final int VK_F4             = 0x73;
  368   
  369       /** Constant for the F5 function key. */
  370       public static final int VK_F5             = 0x74;
  371   
  372       /** Constant for the F6 function key. */
  373       public static final int VK_F6             = 0x75;
  374   
  375       /** Constant for the F7 function key. */
  376       public static final int VK_F7             = 0x76;
  377   
  378       /** Constant for the F8 function key. */
  379       public static final int VK_F8             = 0x77;
  380   
  381       /** Constant for the F9 function key. */
  382       public static final int VK_F9             = 0x78;
  383   
  384       /** Constant for the F10 function key. */
  385       public static final int VK_F10            = 0x79;
  386   
  387       /** Constant for the F11 function key. */
  388       public static final int VK_F11            = 0x7A;
  389   
  390       /** Constant for the F12 function key. */
  391       public static final int VK_F12            = 0x7B;
  392   
  393       /**
  394        * Constant for the F13 function key.
  395        * @since 1.2
  396        */
  397       /* F13 - F24 are used on IBM 3270 keyboard; use random range for constants. */
  398       public static final int VK_F13            = 0xF000;
  399   
  400       /**
  401        * Constant for the F14 function key.
  402        * @since 1.2
  403        */
  404       public static final int VK_F14            = 0xF001;
  405   
  406       /**
  407        * Constant for the F15 function key.
  408        * @since 1.2
  409        */
  410       public static final int VK_F15            = 0xF002;
  411   
  412       /**
  413        * Constant for the F16 function key.
  414        * @since 1.2
  415        */
  416       public static final int VK_F16            = 0xF003;
  417   
  418       /**
  419        * Constant for the F17 function key.
  420        * @since 1.2
  421        */
  422       public static final int VK_F17            = 0xF004;
  423   
  424       /**
  425        * Constant for the F18 function key.
  426        * @since 1.2
  427        */
  428       public static final int VK_F18            = 0xF005;
  429   
  430       /**
  431        * Constant for the F19 function key.
  432        * @since 1.2
  433        */
  434       public static final int VK_F19            = 0xF006;
  435   
  436       /**
  437        * Constant for the F20 function key.
  438        * @since 1.2
  439        */
  440       public static final int VK_F20            = 0xF007;
  441   
  442       /**
  443        * Constant for the F21 function key.
  444        * @since 1.2
  445        */
  446       public static final int VK_F21            = 0xF008;
  447   
  448       /**
  449        * Constant for the F22 function key.
  450        * @since 1.2
  451        */
  452       public static final int VK_F22            = 0xF009;
  453   
  454       /**
  455        * Constant for the F23 function key.
  456        * @since 1.2
  457        */
  458       public static final int VK_F23            = 0xF00A;
  459   
  460       /**
  461        * Constant for the F24 function key.
  462        * @since 1.2
  463        */
  464       public static final int VK_F24            = 0xF00B;
  465   
  466       public static final int VK_PRINTSCREEN    = 0x9A;
  467       public static final int VK_INSERT         = 0x9B;
  468       public static final int VK_HELP           = 0x9C;
  469       public static final int VK_META           = 0x9D;
  470   
  471       public static final int VK_BACK_QUOTE     = 0xC0;
  472       public static final int VK_QUOTE          = 0xDE;
  473   
  474       /**
  475        * Constant for the numeric keypad <b>up</b> arrow key.
  476        * @see #VK_UP
  477        * @since 1.2
  478        */
  479       public static final int VK_KP_UP          = 0xE0;
  480   
  481       /**
  482        * Constant for the numeric keypad <b>down</b> arrow key.
  483        * @see #VK_DOWN
  484        * @since 1.2
  485        */
  486       public static final int VK_KP_DOWN        = 0xE1;
  487   
  488       /**
  489        * Constant for the numeric keypad <b>left</b> arrow key.
  490        * @see #VK_LEFT
  491        * @since 1.2
  492        */
  493       public static final int VK_KP_LEFT        = 0xE2;
  494   
  495       /**
  496        * Constant for the numeric keypad <b>right</b> arrow key.
  497        * @see #VK_RIGHT
  498        * @since 1.2
  499        */
  500       public static final int VK_KP_RIGHT       = 0xE3;
  501   
  502       /* For European keyboards */
  503       /** @since 1.2 */
  504       public static final int VK_DEAD_GRAVE               = 0x80;
  505       /** @since 1.2 */
  506       public static final int VK_DEAD_ACUTE               = 0x81;
  507       /** @since 1.2 */
  508       public static final int VK_DEAD_CIRCUMFLEX          = 0x82;
  509       /** @since 1.2 */
  510       public static final int VK_DEAD_TILDE               = 0x83;
  511       /** @since 1.2 */
  512       public static final int VK_DEAD_MACRON              = 0x84;
  513       /** @since 1.2 */
  514       public static final int VK_DEAD_BREVE               = 0x85;
  515       /** @since 1.2 */
  516       public static final int VK_DEAD_ABOVEDOT            = 0x86;
  517       /** @since 1.2 */
  518       public static final int VK_DEAD_DIAERESIS           = 0x87;
  519       /** @since 1.2 */
  520       public static final int VK_DEAD_ABOVERING           = 0x88;
  521       /** @since 1.2 */
  522       public static final int VK_DEAD_DOUBLEACUTE         = 0x89;
  523       /** @since 1.2 */
  524       public static final int VK_DEAD_CARON               = 0x8a;
  525       /** @since 1.2 */
  526       public static final int VK_DEAD_CEDILLA             = 0x8b;
  527       /** @since 1.2 */
  528       public static final int VK_DEAD_OGONEK              = 0x8c;
  529       /** @since 1.2 */
  530       public static final int VK_DEAD_IOTA                = 0x8d;
  531       /** @since 1.2 */
  532       public static final int VK_DEAD_VOICED_SOUND        = 0x8e;
  533       /** @since 1.2 */
  534       public static final int VK_DEAD_SEMIVOICED_SOUND    = 0x8f;
  535   
  536       /** @since 1.2 */
  537       public static final int VK_AMPERSAND                = 0x96;
  538       /** @since 1.2 */
  539       public static final int VK_ASTERISK                 = 0x97;
  540       /** @since 1.2 */
  541       public static final int VK_QUOTEDBL                 = 0x98;
  542       /** @since 1.2 */
  543       public static final int VK_LESS                     = 0x99;
  544   
  545       /** @since 1.2 */
  546       public static final int VK_GREATER                  = 0xa0;
  547       /** @since 1.2 */
  548       public static final int VK_BRACELEFT                = 0xa1;
  549       /** @since 1.2 */
  550       public static final int VK_BRACERIGHT               = 0xa2;
  551   
  552       /**
  553        * Constant for the "@" key.
  554        * @since 1.2
  555        */
  556       public static final int VK_AT                       = 0x0200;
  557   
  558       /**
  559        * Constant for the ":" key.
  560        * @since 1.2
  561        */
  562       public static final int VK_COLON                    = 0x0201;
  563   
  564       /**
  565        * Constant for the "^" key.
  566        * @since 1.2
  567        */
  568       public static final int VK_CIRCUMFLEX               = 0x0202;
  569   
  570       /**
  571        * Constant for the "$" key.
  572        * @since 1.2
  573        */
  574       public static final int VK_DOLLAR                   = 0x0203;
  575   
  576       /**
  577        * Constant for the Euro currency sign key.
  578        * @since 1.2
  579        */
  580       public static final int VK_EURO_SIGN                = 0x0204;
  581   
  582       /**
  583        * Constant for the "!" key.
  584        * @since 1.2
  585        */
  586       public static final int VK_EXCLAMATION_MARK         = 0x0205;
  587   
  588       /**
  589        * Constant for the inverted exclamation mark key.
  590        * @since 1.2
  591        */
  592       public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206;
  593   
  594       /**
  595        * Constant for the "(" key.
  596        * @since 1.2
  597        */
  598       public static final int VK_LEFT_PARENTHESIS         = 0x0207;
  599   
  600       /**
  601        * Constant for the "#" key.
  602        * @since 1.2
  603        */
  604       public static final int VK_NUMBER_SIGN              = 0x0208;
  605   
  606       /**
  607        * Constant for the "+" key.
  608        * @since 1.2
  609        */
  610       public static final int VK_PLUS                     = 0x0209;
  611   
  612       /**
  613        * Constant for the ")" key.
  614        * @since 1.2
  615        */
  616       public static final int VK_RIGHT_PARENTHESIS        = 0x020A;
  617   
  618       /**
  619        * Constant for the "_" key.
  620        * @since 1.2
  621        */
  622       public static final int VK_UNDERSCORE               = 0x020B;
  623   
  624       /**
  625        * Constant for the Microsoft Windows "Windows" key.
  626        * It is used for both the left and right version of the key.
  627        * @see #getKeyLocation()
  628        * @since 1.5
  629        */
  630       public static final int VK_WINDOWS                  = 0x020C;
  631   
  632       /**
  633        * Constant for the Microsoft Windows Context Menu key.
  634        * @since 1.5
  635        */
  636       public static final int VK_CONTEXT_MENU             = 0x020D;
  637   
  638       /* for input method support on Asian Keyboards */
  639   
  640       /* not clear what this means - listed in Microsoft Windows API */
  641       public static final int VK_FINAL                    = 0x0018;
  642   
  643       /** Constant for the Convert function key. */
  644       /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */
  645       public static final int VK_CONVERT                  = 0x001C;
  646   
  647       /** Constant for the Don't Convert function key. */
  648       /* Japanese PC 106 keyboard: muhenkan */
  649       public static final int VK_NONCONVERT               = 0x001D;
  650   
  651       /** Constant for the Accept or Commit function key. */
  652       /* Japanese Solaris keyboard: kakutei */
  653       public static final int VK_ACCEPT                   = 0x001E;
  654   
  655       /* not clear what this means - listed in Microsoft Windows API */
  656       public static final int VK_MODECHANGE               = 0x001F;
  657   
  658       /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris;
  659          might still be used on other platforms */
  660       public static final int VK_KANA                     = 0x0015;
  661   
  662       /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris;
  663          might still be used for other platforms */
  664       public static final int VK_KANJI                    = 0x0019;
  665   
  666       /**
  667        * Constant for the Alphanumeric function key.
  668        * @since 1.2
  669        */
  670       /* Japanese PC 106 keyboard: eisuu */
  671       public static final int VK_ALPHANUMERIC             = 0x00F0;
  672   
  673       /**
  674        * Constant for the Katakana function key.
  675        * @since 1.2
  676        */
  677       /* Japanese PC 106 keyboard: katakana */
  678       public static final int VK_KATAKANA                 = 0x00F1;
  679   
  680       /**
  681        * Constant for the Hiragana function key.
  682        * @since 1.2
  683        */
  684       /* Japanese PC 106 keyboard: hiragana */
  685       public static final int VK_HIRAGANA                 = 0x00F2;
  686   
  687       /**
  688        * Constant for the Full-Width Characters function key.
  689        * @since 1.2
  690        */
  691       /* Japanese PC 106 keyboard: zenkaku */
  692       public static final int VK_FULL_WIDTH               = 0x00F3;
  693   
  694       /**
  695        * Constant for the Half-Width Characters function key.
  696        * @since 1.2
  697        */
  698       /* Japanese PC 106 keyboard: hankaku */
  699       public static final int VK_HALF_WIDTH               = 0x00F4;
  700   
  701       /**
  702        * Constant for the Roman Characters function key.
  703        * @since 1.2
  704        */
  705       /* Japanese PC 106 keyboard: roumaji */
  706       public static final int VK_ROMAN_CHARACTERS         = 0x00F5;
  707   
  708       /**
  709        * Constant for the All Candidates function key.
  710        * @since 1.2
  711        */
  712       /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */
  713       public static final int VK_ALL_CANDIDATES           = 0x0100;
  714   
  715       /**
  716        * Constant for the Previous Candidate function key.
  717        * @since 1.2
  718        */
  719       /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */
  720       public static final int VK_PREVIOUS_CANDIDATE       = 0x0101;
  721   
  722       /**
  723        * Constant for the Code Input function key.
  724        * @since 1.2
  725        */
  726       /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */
  727       public static final int VK_CODE_INPUT               = 0x0102;
  728   
  729       /**
  730        * Constant for the Japanese-Katakana function key.
  731        * This key switches to a Japanese input method and selects its Katakana input mode.
  732        * @since 1.2
  733        */
  734       /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */
  735       public static final int VK_JAPANESE_KATAKANA        = 0x0103;
  736   
  737       /**
  738        * Constant for the Japanese-Hiragana function key.
  739        * This key switches to a Japanese input method and selects its Hiragana input mode.
  740        * @since 1.2
  741        */
  742       /* Japanese Macintosh keyboard */
  743       public static final int VK_JAPANESE_HIRAGANA        = 0x0104;
  744   
  745       /**
  746        * Constant for the Japanese-Roman function key.
  747        * This key switches to a Japanese input method and selects its Roman-Direct input mode.
  748        * @since 1.2
  749        */
  750       /* Japanese Macintosh keyboard */
  751       public static final int VK_JAPANESE_ROMAN           = 0x0105;
  752   
  753       /**
  754        * Constant for the locking Kana function key.
  755        * This key locks the keyboard into a Kana layout.
  756        * @since 1.3
  757        */
  758       /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */
  759       public static final int VK_KANA_LOCK                = 0x0106;
  760   
  761       /**
  762        * Constant for the input method on/off key.
  763        * @since 1.3
  764        */
  765       /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */
  766       public static final int VK_INPUT_METHOD_ON_OFF      = 0x0107;
  767   
  768       /* for Sun keyboards */
  769       /** @since 1.2 */
  770       public static final int VK_CUT                      = 0xFFD1;
  771       /** @since 1.2 */
  772       public static final int VK_COPY                     = 0xFFCD;
  773       /** @since 1.2 */
  774       public static final int VK_PASTE                    = 0xFFCF;
  775       /** @since 1.2 */
  776       public static final int VK_UNDO                     = 0xFFCB;
  777       /** @since 1.2 */
  778       public static final int VK_AGAIN                    = 0xFFC9;
  779       /** @since 1.2 */
  780       public static final int VK_FIND                     = 0xFFD0;
  781       /** @since 1.2 */
  782       public static final int VK_PROPS                    = 0xFFCA;
  783       /** @since 1.2 */
  784       public static final int VK_STOP                     = 0xFFC8;
  785   
  786       /**
  787        * Constant for the Compose function key.
  788        * @since 1.2
  789        */
  790       public static final int VK_COMPOSE                  = 0xFF20;
  791   
  792       /**
  793        * Constant for the AltGraph function key.
  794        * @since 1.2
  795        */
  796       public static final int VK_ALT_GRAPH                = 0xFF7E;
  797   
  798       /**
  799        * Constant for the Begin key.
  800        * @since 1.5
  801        */
  802       public static final int VK_BEGIN                    = 0xFF58;
  803   
  804       /**
  805        * This value is used to indicate that the keyCode is unknown.
  806        * KEY_TYPED events do not have a keyCode value; this value
  807        * is used instead.
  808        */
  809       public static final int VK_UNDEFINED      = 0x0;
  810   
  811       /**
  812        * KEY_PRESSED and KEY_RELEASED events which do not map to a
  813        * valid Unicode character use this for the keyChar value.
  814        */
  815       public static final char CHAR_UNDEFINED   = 0xFFFF;
  816   
  817       /**
  818        * A constant indicating that the keyLocation is indeterminate
  819        * or not relevant.
  820        * <code>KEY_TYPED</code> events do not have a keyLocation; this value
  821        * is used instead.
  822        * @since 1.4
  823        */
  824       public static final int KEY_LOCATION_UNKNOWN  = 0;
  825   
  826       /**
  827        * A constant indicating that the key pressed or released
  828        * is not distinguished as the left or right version of a key,
  829        * and did not originate on the numeric keypad (or did not
  830        * originate with a virtual key corresponding to the numeric
  831        * keypad).
  832        * @since 1.4
  833        */
  834       public static final int KEY_LOCATION_STANDARD = 1;
  835   
  836       /**
  837        * A constant indicating that the key pressed or released is in
  838        * the left key location (there is more than one possible location
  839        * for this key).  Example: the left shift key.
  840        * @since 1.4
  841        */
  842       public static final int KEY_LOCATION_LEFT     = 2;
  843   
  844       /**
  845        * A constant indicating that the key pressed or released is in
  846        * the right key location (there is more than one possible location
  847        * for this key).  Example: the right shift key.
  848        * @since 1.4
  849        */
  850       public static final int KEY_LOCATION_RIGHT    = 3;
  851   
  852       /**
  853        * A constant indicating that the key event originated on the
  854        * numeric keypad or with a virtual key corresponding to the
  855        * numeric keypad.
  856        * @since 1.4
  857        */
  858       public static final int KEY_LOCATION_NUMPAD   = 4;
  859   
  860       /**
  861        * The unique value assigned to each of the keys on the
  862        * keyboard.  There is a common set of key codes that
  863        * can be fired by most keyboards.
  864        * The symbolic name for a key code should be used rather
  865        * than the code value itself.
  866        *
  867        * @serial
  868        * @see #getKeyCode()
  869        * @see #setKeyCode(int)
  870        */
  871       int  keyCode;
  872   
  873       /**
  874        * <code>keyChar</code> is a valid unicode character
  875        * that is fired by a key or a key combination on
  876        * a keyboard.
  877        *
  878        * @serial
  879        * @see #getKeyChar()
  880        * @see #setKeyChar(char)
  881        */
  882       char keyChar;
  883   
  884       /**
  885        * The location of the key on the keyboard.
  886        *
  887        * Some keys occur more than once on a keyboard, e.g. the left and
  888        * right shift keys.  Additionally, some keys occur on the numeric
  889        * keypad.  This variable is used to distinguish such keys.
  890        *
  891        * The only legal values are <code>KEY_LOCATION_UNKNOWN</code>,
  892        * <code>KEY_LOCATION_STANDARD</code>, <code>KEY_LOCATION_LEFT</code>,
  893        * <code>KEY_LOCATION_RIGHT</code>, and <code>KEY_LOCATION_NUMPAD</code>.
  894        *
  895        * @serial
  896        * @see #getKeyLocation()
  897        */
  898       int keyLocation;
  899   
  900       //set from native code.
  901       private transient long rawCode = 0;
  902       private transient long primaryLevelUnicode = 0;
  903       private transient long scancode = 0; // for MS Windows only
  904       private transient long extendedKeyCode = 0;
  905   
  906       /*
  907        * JDK 1.1 serialVersionUID
  908        */
  909       private static final long serialVersionUID = -2352130953028126954L;
  910   
  911       static {
  912           /* ensure that the necessary native libraries are loaded */
  913           NativeLibLoader.loadLibraries();
  914           if (!GraphicsEnvironment.isHeadless()) {
  915               initIDs();
  916           }
  917       }
  918   
  919       /**
  920        * Initialize JNI field and method IDs for fields that may be
  921        * accessed from C.
  922        */
  923       private static native void initIDs();
  924   
  925       private KeyEvent(Component source, int id, long when, int modifiers,
  926                       int keyCode, char keyChar, int keyLocation, boolean isProxyActive) {
  927           this(source, id, when, modifiers, keyCode, keyChar, keyLocation);
  928           this.isProxyActive = isProxyActive;
  929       }
  930   
  931       /**
  932        * Constructs a <code>KeyEvent</code> object.
  933        * <p>This method throws an
  934        * <code>IllegalArgumentException</code> if <code>source</code>
  935        * is <code>null</code>.
  936        *
  937        * @param source    The <code>Component</code> that originated the event
  938        * @param id              An integer indicating the type of event.
  939        *                  For information on allowable values, see
  940        *                  the class description for {@link KeyEvent}
  941        * @param when      A long integer that specifies the time the event
  942        *                  occurred.
  943        *                     Passing negative or zero value
  944        *                     is not recommended
  945        * @param modifiers The modifier keys down during event (shift, ctrl,
  946        *                  alt, meta).
  947        *                     Passing negative value
  948        *                     is not recommended.
  949        *                     Zero value means that no modifiers were passed.
  950        *                  Use either an extended _DOWN_MASK or old _MASK modifiers,
  951        *                  however do not mix models in the one event.
  952        *                  The extended modifiers are preferred for using
  953        * @param keyCode   The integer code for an actual key, or VK_UNDEFINED
  954        *                  (for a key-typed event)
  955        * @param keyChar   The Unicode character generated by this event, or
  956        *                  CHAR_UNDEFINED (for key-pressed and key-released
  957        *                  events which do not map to a valid Unicode character)
  958        * @param keyLocation  Identifies the key location.  The only legal
  959        *        values are <code>KEY_LOCATION_UNKNOWN</code>,
  960        *        <code>KEY_LOCATION_STANDARD</code>, <code>KEY_LOCATION_LEFT</code>,
  961        *        <code>KEY_LOCATION_RIGHT</code>, and <code>KEY_LOCATION_NUMPAD</code>.
  962        * @throws IllegalArgumentException
  963        *     if <code>id</code> is <code>KEY_TYPED</code> and
  964        *       <code>keyChar</code> is <code>CHAR_UNDEFINED</code>;
  965        *     or if <code>id</code> is <code>KEY_TYPED</code> and
  966        *       <code>keyCode</code> is not <code>VK_UNDEFINED</code>;
  967        *     or if <code>id</code> is <code>KEY_TYPED</code> and
  968        *       <code>keyLocation</code> is not <code>KEY_LOCATION_UNKNOWN</code>;
  969        *     or if <code>keyLocation</code> is not one of the legal
  970        *       values enumerated above.
  971        * @throws IllegalArgumentException if <code>source</code> is null
  972        * @see #getSource()
  973        * @see #getID()
  974        * @see #getWhen()
  975        * @see #getModifiers()
  976        * @see #getKeyCode()
  977        * @see #getKeyChar()
  978        * @see #getKeyLocation()
  979        * @since 1.4
  980        */
  981       public KeyEvent(Component source, int id, long when, int modifiers,
  982                       int keyCode, char keyChar, int keyLocation) {
  983           super(source, id, when, modifiers);
  984           if (id == KEY_TYPED) {
  985               if (keyChar == CHAR_UNDEFINED) {
  986                   throw new IllegalArgumentException("invalid keyChar");
  987               }
  988               if (keyCode != VK_UNDEFINED) {
  989                   throw new IllegalArgumentException("invalid keyCode");
  990               }
  991               if (keyLocation != KEY_LOCATION_UNKNOWN) {
  992                   throw new IllegalArgumentException("invalid keyLocation");
  993               }
  994           }
  995   
  996           this.keyCode = keyCode;
  997           this.keyChar = keyChar;
  998   
  999           if ((keyLocation < KEY_LOCATION_UNKNOWN) ||
 1000               (keyLocation > KEY_LOCATION_NUMPAD)) {
 1001               throw new IllegalArgumentException("invalid keyLocation");
 1002           }
 1003           this.keyLocation = keyLocation;
 1004           if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
 1005               setNewModifiers();
 1006           } else if ((getModifiers() == 0) && (getModifiersEx() != 0)) {
 1007               setOldModifiers();
 1008           }
 1009       }
 1010   
 1011       /**
 1012        * Constructs a <code>KeyEvent</code> object.
 1013        * <p> This method throws an
 1014        * <code>IllegalArgumentException</code> if <code>source</code>
 1015        * is <code>null</code>.
 1016        *
 1017        * @param source    The <code>Component</code> that originated the event
 1018        * @param id              An integer indicating the type of event.
 1019        *                  For information on allowable values, see
 1020        *                  the class description for {@link KeyEvent}
 1021        * @param when      A long integer that specifies the time the event
 1022        *                  occurred.
 1023        *                     Passing negative or zero value
 1024        *                     is not recommended
 1025        * @param modifiers The modifier keys down during event (shift, ctrl,
 1026        *                  alt, meta).
 1027        *                     Passing negative value
 1028        *                     is not recommended.
 1029        *                     Zero value means that no modifiers were passed.
 1030        *                  Use either an extended _DOWN_MASK or old _MASK modifiers,
 1031        *                  however do not mix models in the one event.
 1032        *                  The extended modifiers are preferred for using
 1033        * @param keyCode   The integer code for an actual key, or VK_UNDEFINED
 1034        *                  (for a key-typed event)
 1035        * @param keyChar   The Unicode character generated by this event, or
 1036        *                  CHAR_UNDEFINED (for key-pressed and key-released
 1037        *                  events which do not map to a valid Unicode character)
 1038        * @throws IllegalArgumentException  if <code>id</code> is
 1039        *     <code>KEY_TYPED</code> and <code>keyChar</code> is
 1040        *     <code>CHAR_UNDEFINED</code>; or if <code>id</code> is
 1041        *     <code>KEY_TYPED</code> and <code>keyCode</code> is not
 1042        *     <code>VK_UNDEFINED</code>
 1043        * @throws IllegalArgumentException if <code>source</code> is null
 1044        * @see #getSource()
 1045        * @see #getID()
 1046        * @see #getWhen()
 1047        * @see #getModifiers()
 1048        * @see #getKeyCode()
 1049        * @see #getKeyChar()
 1050        */
 1051       public KeyEvent(Component source, int id, long when, int modifiers,
 1052                       int keyCode, char keyChar) {
 1053           this(source, id, when, modifiers, keyCode, keyChar,
 1054             KEY_LOCATION_UNKNOWN);
 1055       }
 1056   
 1057       /**
 1058        * @deprecated as of JDK1.1
 1059        */
 1060       @Deprecated
 1061       public KeyEvent(Component source, int id, long when, int modifiers,
 1062                       int keyCode) {
 1063           this(source, id, when, modifiers, keyCode, (char)keyCode);
 1064       }
 1065   
 1066       /**
 1067        * Returns the integer keyCode associated with the key in this event.
 1068        *
 1069        * @return the integer code for an actual key on the keyboard.
 1070        *         (For <code>KEY_TYPED</code> events, the keyCode is
 1071        *         <code>VK_UNDEFINED</code>.)
 1072        */
 1073       public int getKeyCode() {
 1074           return keyCode;
 1075       }
 1076   
 1077       /**
 1078        * Set the keyCode value to indicate a physical key.
 1079        *
 1080        * @param keyCode an integer corresponding to an actual key on the keyboard.
 1081        */
 1082       public void setKeyCode(int keyCode) {
 1083           this.keyCode = keyCode;
 1084       }
 1085   
 1086       /**
 1087        * Returns the character associated with the key in this event.
 1088        * For example, the <code>KEY_TYPED</code> event for shift + "a"
 1089        * returns the value for "A".
 1090        * <p>
 1091        * <code>KEY_PRESSED</code> and <code>KEY_RELEASED</code> events
 1092        * are not intended for reporting of character input.  Therefore,
 1093        * the values returned by this method are guaranteed to be
 1094        * meaningful only for <code>KEY_TYPED</code> events.
 1095        *
 1096        * @return the Unicode character defined for this key event.
 1097        *         If no valid Unicode character exists for this key event,
 1098        *         <code>CHAR_UNDEFINED</code> is returned.
 1099        */
 1100       public char getKeyChar() {
 1101           return keyChar;
 1102       }
 1103   
 1104       /**
 1105        * Set the keyChar value to indicate a logical character.
 1106        *
 1107        * @param keyChar a char corresponding to to the combination of keystrokes
 1108        *                that make up this event.
 1109        */
 1110       public void setKeyChar(char keyChar) {
 1111           this.keyChar = keyChar;
 1112       }
 1113   
 1114       /**
 1115        * Set the modifiers to indicate additional keys that were held down
 1116        * (e.g. shift, ctrl, alt, meta) defined as part of InputEvent.
 1117        * <p>
 1118        * NOTE:  use of this method is not recommended, because many AWT
 1119        * implementations do not recognize modifier changes.  This is
 1120        * especially true for <code>KEY_TYPED</code> events where the shift
 1121        * modifier is changed.
 1122        *
 1123        * @param modifiers an integer combination of the modifier constants.
 1124        * @see InputEvent
 1125        * @deprecated as of JDK1.1.4
 1126        */
 1127       @Deprecated
 1128       public void setModifiers(int modifiers) {
 1129           this.modifiers = modifiers;
 1130           if ((getModifiers() != 0) && (getModifiersEx() == 0)) {
 1131               setNewModifiers();
 1132           } else if ((getModifiers() == 0) && (getModifiersEx() != 0)) {
 1133               setOldModifiers();
 1134           }
 1135       }
 1136   
 1137       /**
 1138        * Returns the location of the key that originated this key event.
 1139        *
 1140        * Some keys occur more than once on a keyboard, e.g. the left and
 1141        * right shift keys.  Additionally, some keys occur on the numeric
 1142        * keypad.  This provides a way of distinguishing such keys.
 1143        *
 1144        * @return the location of the key that was pressed or released.
 1145        *         Always returns <code>KEY_LOCATION_UNKNOWN</code> for
 1146        *         <code>KEY_TYPED</code> events.
 1147        * @since 1.4
 1148        */
 1149       public int getKeyLocation() {
 1150           return keyLocation;
 1151       }
 1152   
 1153       /**
 1154        * Returns a String describing the keyCode, such as "HOME", "F1" or "A".
 1155        * These strings can be localized by changing the awt.properties file.
 1156        *
 1157        * @return a string containing a text description for a physical key,
 1158        *         identified by its keyCode
 1159        */
 1160       public static String getKeyText(int keyCode) {
 1161           if (keyCode >= VK_0 && keyCode <= VK_9 ||
 1162               keyCode >= VK_A && keyCode <= VK_Z) {
 1163               return String.valueOf((char)keyCode);
 1164           }
 1165   
 1166           switch(keyCode) {
 1167             case VK_ENTER: return Toolkit.getProperty("AWT.enter", "Enter");
 1168             case VK_BACK_SPACE: return Toolkit.getProperty("AWT.backSpace", "Backspace");
 1169             case VK_TAB: return Toolkit.getProperty("AWT.tab", "Tab");
 1170             case VK_CANCEL: return Toolkit.getProperty("AWT.cancel", "Cancel");
 1171             case VK_CLEAR: return Toolkit.getProperty("AWT.clear", "Clear");
 1172             case VK_COMPOSE: return Toolkit.getProperty("AWT.compose", "Compose");
 1173             case VK_PAUSE: return Toolkit.getProperty("AWT.pause", "Pause");
 1174             case VK_CAPS_LOCK: return Toolkit.getProperty("AWT.capsLock", "Caps Lock");
 1175             case VK_ESCAPE: return Toolkit.getProperty("AWT.escape", "Escape");
 1176             case VK_SPACE: return Toolkit.getProperty("AWT.space", "Space");
 1177             case VK_PAGE_UP: return Toolkit.getProperty("AWT.pgup", "Page Up");
 1178             case VK_PAGE_DOWN: return Toolkit.getProperty("AWT.pgdn", "Page Down");
 1179             case VK_END: return Toolkit.getProperty("AWT.end", "End");
 1180             case VK_HOME: return Toolkit.getProperty("AWT.home", "Home");
 1181             case VK_LEFT: return Toolkit.getProperty("AWT.left", "Left");
 1182             case VK_UP: return Toolkit.getProperty("AWT.up", "Up");
 1183             case VK_RIGHT: return Toolkit.getProperty("AWT.right", "Right");
 1184             case VK_DOWN: return Toolkit.getProperty("AWT.down", "Down");
 1185             case VK_BEGIN: return Toolkit.getProperty("AWT.begin", "Begin");
 1186   
 1187             // modifiers
 1188             case VK_SHIFT: return Toolkit.getProperty("AWT.shift", "Shift");
 1189             case VK_CONTROL: return Toolkit.getProperty("AWT.control", "Control");
 1190             case VK_ALT: return Toolkit.getProperty("AWT.alt", "Alt");
 1191             case VK_META: return Toolkit.getProperty("AWT.meta", "Meta");
 1192             case VK_ALT_GRAPH: return Toolkit.getProperty("AWT.altGraph", "Alt Graph");
 1193   
 1194             // punctuation
 1195             case VK_COMMA: return Toolkit.getProperty("AWT.comma", "Comma");
 1196             case VK_PERIOD: return Toolkit.getProperty("AWT.period", "Period");
 1197             case VK_SLASH: return Toolkit.getProperty("AWT.slash", "Slash");
 1198             case VK_SEMICOLON: return Toolkit.getProperty("AWT.semicolon", "Semicolon");
 1199             case VK_EQUALS: return Toolkit.getProperty("AWT.equals", "Equals");
 1200             case VK_OPEN_BRACKET: return Toolkit.getProperty("AWT.openBracket", "Open Bracket");
 1201             case VK_BACK_SLASH: return Toolkit.getProperty("AWT.backSlash", "Back Slash");
 1202             case VK_CLOSE_BRACKET: return Toolkit.getProperty("AWT.closeBracket", "Close Bracket");
 1203   
 1204             // numpad numeric keys handled below
 1205             case VK_MULTIPLY: return Toolkit.getProperty("AWT.multiply", "NumPad *");
 1206             case VK_ADD: return Toolkit.getProperty("AWT.add", "NumPad +");
 1207             case VK_SEPARATOR: return Toolkit.getProperty("AWT.separator", "NumPad ,");
 1208             case VK_SUBTRACT: return Toolkit.getProperty("AWT.subtract", "NumPad -");
 1209             case VK_DECIMAL: return Toolkit.getProperty("AWT.decimal", "NumPad .");
 1210             case VK_DIVIDE: return Toolkit.getProperty("AWT.divide", "NumPad /");
 1211             case VK_DELETE: return Toolkit.getProperty("AWT.delete", "Delete");
 1212             case VK_NUM_LOCK: return Toolkit.getProperty("AWT.numLock", "Num Lock");
 1213             case VK_SCROLL_LOCK: return Toolkit.getProperty("AWT.scrollLock", "Scroll Lock");
 1214   
 1215             case VK_WINDOWS: return Toolkit.getProperty("AWT.windows", "Windows");
 1216             case VK_CONTEXT_MENU: return Toolkit.getProperty("AWT.context", "Context Menu");
 1217   
 1218             case VK_F1: return Toolkit.getProperty("AWT.f1", "F1");
 1219             case VK_F2: return Toolkit.getProperty("AWT.f2", "F2");
 1220             case VK_F3: return Toolkit.getProperty("AWT.f3", "F3");
 1221             case VK_F4: return Toolkit.getProperty("AWT.f4", "F4");
 1222             case VK_F5: return Toolkit.getProperty("AWT.f5", "F5");
 1223             case VK_F6: return Toolkit.getProperty("AWT.f6", "F6");
 1224             case VK_F7: return Toolkit.getProperty("AWT.f7", "F7");
 1225             case VK_F8: return Toolkit.getProperty("AWT.f8", "F8");
 1226             case VK_F9: return Toolkit.getProperty("AWT.f9", "F9");
 1227             case VK_F10: return Toolkit.getProperty("AWT.f10", "F10");
 1228             case VK_F11: return Toolkit.getProperty("AWT.f11", "F11");
 1229             case VK_F12: return Toolkit.getProperty("AWT.f12", "F12");
 1230             case VK_F13: return Toolkit.getProperty("AWT.f13", "F13");
 1231             case VK_F14: return Toolkit.getProperty("AWT.f14", "F14");
 1232             case VK_F15: return Toolkit.getProperty("AWT.f15", "F15");
 1233             case VK_F16: return Toolkit.getProperty("AWT.f16", "F16");
 1234             case VK_F17: return Toolkit.getProperty("AWT.f17", "F17");
 1235             case VK_F18: return Toolkit.getProperty("AWT.f18", "F18");
 1236             case VK_F19: return Toolkit.getProperty("AWT.f19", "F19");
 1237             case VK_F20: return Toolkit.getProperty("AWT.f20", "F20");
 1238             case VK_F21: return Toolkit.getProperty("AWT.f21", "F21");
 1239             case VK_F22: return Toolkit.getProperty("AWT.f22", "F22");
 1240             case VK_F23: return Toolkit.getProperty("AWT.f23", "F23");
 1241             case VK_F24: return Toolkit.getProperty("AWT.f24", "F24");
 1242   
 1243             case VK_PRINTSCREEN: return Toolkit.getProperty("AWT.printScreen", "Print Screen");
 1244             case VK_INSERT: return Toolkit.getProperty("AWT.insert", "Insert");
 1245             case VK_HELP: return Toolkit.getProperty("AWT.help", "Help");
 1246             case VK_BACK_QUOTE: return Toolkit.getProperty("AWT.backQuote", "Back Quote");
 1247             case VK_QUOTE: return Toolkit.getProperty("AWT.quote", "Quote");
 1248   
 1249             case VK_KP_UP: return Toolkit.getProperty("AWT.up", "Up");
 1250             case VK_KP_DOWN: return Toolkit.getProperty("AWT.down", "Down");
 1251             case VK_KP_LEFT: return Toolkit.getProperty("AWT.left", "Left");
 1252             case VK_KP_RIGHT: return Toolkit.getProperty("AWT.right", "Right");
 1253   
 1254             case VK_DEAD_GRAVE: return Toolkit.getProperty("AWT.deadGrave", "Dead Grave");
 1255             case VK_DEAD_ACUTE: return Toolkit.getProperty("AWT.deadAcute", "Dead Acute");
 1256             case VK_DEAD_CIRCUMFLEX: return Toolkit.getProperty("AWT.deadCircumflex", "Dead Circumflex");
 1257             case VK_DEAD_TILDE: return Toolkit.getProperty("AWT.deadTilde", "Dead Tilde");
 1258             case VK_DEAD_MACRON: return Toolkit.getProperty("AWT.deadMacron", "Dead Macron");
 1259             case VK_DEAD_BREVE: return Toolkit.getProperty("AWT.deadBreve", "Dead Breve");
 1260             case VK_DEAD_ABOVEDOT: return Toolkit.getProperty("AWT.deadAboveDot", "Dead Above Dot");
 1261             case VK_DEAD_DIAERESIS: return Toolkit.getProperty("AWT.deadDiaeresis", "Dead Diaeresis");
 1262             case VK_DEAD_ABOVERING: return Toolkit.getProperty("AWT.deadAboveRing", "Dead Above Ring");
 1263             case VK_DEAD_DOUBLEACUTE: return Toolkit.getProperty("AWT.deadDoubleAcute", "Dead Double Acute");
 1264             case VK_DEAD_CARON: return Toolkit.getProperty("AWT.deadCaron", "Dead Caron");
 1265             case VK_DEAD_CEDILLA: return Toolkit.getProperty("AWT.deadCedilla", "Dead Cedilla");
 1266             case VK_DEAD_OGONEK: return Toolkit.getProperty("AWT.deadOgonek", "Dead Ogonek");
 1267             case VK_DEAD_IOTA: return Toolkit.getProperty("AWT.deadIota", "Dead Iota");
 1268             case VK_DEAD_VOICED_SOUND: return Toolkit.getProperty("AWT.deadVoicedSound", "Dead Voiced Sound");
 1269             case VK_DEAD_SEMIVOICED_SOUND: return Toolkit.getProperty("AWT.deadSemivoicedSound", "Dead Semivoiced Sound");
 1270   
 1271             case VK_AMPERSAND: return Toolkit.getProperty("AWT.ampersand", "Ampersand");
 1272             case VK_ASTERISK: return Toolkit.getProperty("AWT.asterisk", "Asterisk");
 1273             case VK_QUOTEDBL: return Toolkit.getProperty("AWT.quoteDbl", "Double Quote");
 1274             case VK_LESS: return Toolkit.getProperty("AWT.Less", "Less");
 1275             case VK_GREATER: return Toolkit.getProperty("AWT.greater", "Greater");
 1276             case VK_BRACELEFT: return Toolkit.getProperty("AWT.braceLeft", "Left Brace");
 1277             case VK_BRACERIGHT: return Toolkit.getProperty("AWT.braceRight", "Right Brace");
 1278             case VK_AT: return Toolkit.getProperty("AWT.at", "At");
 1279             case VK_COLON: return Toolkit.getProperty("AWT.colon", "Colon");
 1280             case VK_CIRCUMFLEX: return Toolkit.getProperty("AWT.circumflex", "Circumflex");
 1281             case VK_DOLLAR: return Toolkit.getProperty("AWT.dollar", "Dollar");
 1282             case VK_EURO_SIGN: return Toolkit.getProperty("AWT.euro", "Euro");
 1283             case VK_EXCLAMATION_MARK: return Toolkit.getProperty("AWT.exclamationMark", "Exclamation Mark");
 1284             case VK_INVERTED_EXCLAMATION_MARK: return Toolkit.getProperty("AWT.invertedExclamationMark", "Inverted Exclamation Mark");
 1285             case VK_LEFT_PARENTHESIS: return Toolkit.getProperty("AWT.leftParenthesis", "Left Parenthesis");
 1286             case VK_NUMBER_SIGN: return Toolkit.getProperty("AWT.numberSign", "Number Sign");
 1287             case VK_MINUS: return Toolkit.getProperty("AWT.minus", "Minus");
 1288             case VK_PLUS: return Toolkit.getProperty("AWT.plus", "Plus");
 1289             case VK_RIGHT_PARENTHESIS: return Toolkit.getProperty("AWT.rightParenthesis", "Right Parenthesis");
 1290             case VK_UNDERSCORE: return Toolkit.getProperty("AWT.underscore", "Underscore");
 1291   
 1292             case VK_FINAL: return Toolkit.getProperty("AWT.final", "Final");
 1293             case VK_CONVERT: return Toolkit.getProperty("AWT.convert", "Convert");
 1294             case VK_NONCONVERT: return Toolkit.getProperty("AWT.noconvert", "No Convert");
 1295             case VK_ACCEPT: return Toolkit.getProperty("AWT.accept", "Accept");
 1296             case VK_MODECHANGE: return Toolkit.getProperty("AWT.modechange", "Mode Change");
 1297             case VK_KANA: return Toolkit.getProperty("AWT.kana", "Kana");
 1298             case VK_KANJI: return Toolkit.getProperty("AWT.kanji", "Kanji");
 1299             case VK_ALPHANUMERIC: return Toolkit.getProperty("AWT.alphanumeric", "Alphanumeric");
 1300             case VK_KATAKANA: return Toolkit.getProperty("AWT.katakana", "Katakana");
 1301             case VK_HIRAGANA: return Toolkit.getProperty("AWT.hiragana", "Hiragana");
 1302             case VK_FULL_WIDTH: return Toolkit.getProperty("AWT.fullWidth", "Full-Width");
 1303             case VK_HALF_WIDTH: return Toolkit.getProperty("AWT.halfWidth", "Half-Width");
 1304             case VK_ROMAN_CHARACTERS: return Toolkit.getProperty("AWT.romanCharacters", "Roman Characters");
 1305             case VK_ALL_CANDIDATES: return Toolkit.getProperty("AWT.allCandidates", "All Candidates");
 1306             case VK_PREVIOUS_CANDIDATE: return Toolkit.getProperty("AWT.previousCandidate", "Previous Candidate");
 1307             case VK_CODE_INPUT: return Toolkit.getProperty("AWT.codeInput", "Code Input");
 1308             case VK_JAPANESE_KATAKANA: return Toolkit.getProperty("AWT.japaneseKatakana", "Japanese Katakana");
 1309             case VK_JAPANESE_HIRAGANA: return Toolkit.getProperty("AWT.japaneseHiragana", "Japanese Hiragana");
 1310             case VK_JAPANESE_ROMAN: return Toolkit.getProperty("AWT.japaneseRoman", "Japanese Roman");
 1311             case VK_KANA_LOCK: return Toolkit.getProperty("AWT.kanaLock", "Kana Lock");
 1312             case VK_INPUT_METHOD_ON_OFF: return Toolkit.getProperty("AWT.inputMethodOnOff", "Input Method On/Off");
 1313   
 1314             case VK_AGAIN: return Toolkit.getProperty("AWT.again", "Again");
 1315             case VK_UNDO: return Toolkit.getProperty("AWT.undo", "Undo");
 1316             case VK_COPY: return Toolkit.getProperty("AWT.copy", "Copy");
 1317             case VK_PASTE: return Toolkit.getProperty("AWT.paste", "Paste");
 1318             case VK_CUT: return Toolkit.getProperty("AWT.cut", "Cut");
 1319             case VK_FIND: return Toolkit.getProperty("AWT.find", "Find");
 1320             case VK_PROPS: return Toolkit.getProperty("AWT.props", "Props");
 1321             case VK_STOP: return Toolkit.getProperty("AWT.stop", "Stop");
 1322           }
 1323   
 1324           if (keyCode >= VK_NUMPAD0 && keyCode <= VK_NUMPAD9) {
 1325               String numpad = Toolkit.getProperty("AWT.numpad", "NumPad");
 1326               char c = (char)(keyCode - VK_NUMPAD0 + '0');
 1327               return numpad + "-" + c;
 1328           }
 1329   
 1330           if ((keyCode & 0x01000000) != 0) {
 1331               return String.valueOf((char)(keyCode ^ 0x01000000 ));
 1332           }
 1333           String unknown = Toolkit.getProperty("AWT.unknown", "Unknown");
 1334           return unknown + " keyCode: 0x" + Integer.toString(keyCode, 16);
 1335       }
 1336   
 1337       /**
 1338        * Returns a <code>String</code> describing the modifier key(s),
 1339        * such as "Shift", or "Ctrl+Shift".  These strings can be
 1340        * localized by changing the <code>awt.properties</code> file.
 1341        * <p>
 1342        * Note that <code>InputEvent.ALT_MASK</code> and
 1343        * <code>InputEvent.BUTTON2_MASK</code> have the same value,
 1344        * so the string "Alt" is returned for both modifiers.  Likewise,
 1345        * <code>InputEvent.META_MASK</code> and
 1346        * <code>InputEvent.BUTTON3_MASK</code> have the same value,
 1347        * so the string "Meta" is returned for both modifiers.
 1348        *
 1349        * @return string a text description of the combination of modifier
 1350        *                keys that were held down during the event
 1351        * @see InputEvent#getModifiersExText(int)
 1352        */
 1353       public static String getKeyModifiersText(int modifiers) {
 1354           StringBuilder buf = new StringBuilder();
 1355           if ((modifiers & InputEvent.META_MASK) != 0) {
 1356               buf.append(Toolkit.getProperty("AWT.meta", "Meta"));
 1357               buf.append("+");
 1358           }
 1359           if ((modifiers & InputEvent.CTRL_MASK) != 0) {
 1360               buf.append(Toolkit.getProperty("AWT.control", "Ctrl"));
 1361               buf.append("+");
 1362           }
 1363           if ((modifiers & InputEvent.ALT_MASK) != 0) {
 1364               buf.append(Toolkit.getProperty("AWT.alt", "Alt"));
 1365               buf.append("+");
 1366           }
 1367           if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
 1368               buf.append(Toolkit.getProperty("AWT.shift", "Shift"));
 1369               buf.append("+");
 1370           }
 1371           if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
 1372               buf.append(Toolkit.getProperty("AWT.altGraph", "Alt Graph"));
 1373               buf.append("+");
 1374           }
 1375           if ((modifiers & InputEvent.BUTTON1_MASK) != 0) {
 1376               buf.append(Toolkit.getProperty("AWT.button1", "Button1"));
 1377               buf.append("+");
 1378           }
 1379           if (buf.length() > 0) {
 1380               buf.setLength(buf.length()-1); // remove trailing '+'
 1381           }
 1382           return buf.toString();
 1383       }
 1384   
 1385   
 1386       /**
 1387        * Returns whether the key in this event is an "action" key.
 1388        * Typically an action key does not fire a unicode character and is
 1389        * not a modifier key.
 1390        *
 1391        * @return <code>true</code> if the key is an "action" key,
 1392        *         <code>false</code> otherwise
 1393        */
 1394       public boolean isActionKey() {
 1395           switch (keyCode) {
 1396             case VK_HOME:
 1397             case VK_END:
 1398             case VK_PAGE_UP:
 1399             case VK_PAGE_DOWN:
 1400             case VK_UP:
 1401             case VK_DOWN:
 1402             case VK_LEFT:
 1403             case VK_RIGHT:
 1404             case VK_BEGIN:
 1405   
 1406             case VK_KP_LEFT:
 1407             case VK_KP_UP:
 1408             case VK_KP_RIGHT:
 1409             case VK_KP_DOWN:
 1410   
 1411             case VK_F1:
 1412             case VK_F2:
 1413             case VK_F3:
 1414             case VK_F4:
 1415             case VK_F5:
 1416             case VK_F6:
 1417             case VK_F7:
 1418             case VK_F8:
 1419             case VK_F9:
 1420             case VK_F10:
 1421             case VK_F11:
 1422             case VK_F12:
 1423             case VK_F13:
 1424             case VK_F14:
 1425             case VK_F15:
 1426             case VK_F16:
 1427             case VK_F17:
 1428             case VK_F18:
 1429             case VK_F19:
 1430             case VK_F20:
 1431             case VK_F21:
 1432             case VK_F22:
 1433             case VK_F23:
 1434             case VK_F24:
 1435             case VK_PRINTSCREEN:
 1436             case VK_SCROLL_LOCK:
 1437             case VK_CAPS_LOCK:
 1438             case VK_NUM_LOCK:
 1439             case VK_PAUSE:
 1440             case VK_INSERT:
 1441   
 1442             case VK_FINAL:
 1443             case VK_CONVERT:
 1444             case VK_NONCONVERT:
 1445             case VK_ACCEPT:
 1446             case VK_MODECHANGE:
 1447             case VK_KANA:
 1448             case VK_KANJI:
 1449             case VK_ALPHANUMERIC:
 1450             case VK_KATAKANA:
 1451             case VK_HIRAGANA:
 1452             case VK_FULL_WIDTH:
 1453             case VK_HALF_WIDTH:
 1454             case VK_ROMAN_CHARACTERS:
 1455             case VK_ALL_CANDIDATES:
 1456             case VK_PREVIOUS_CANDIDATE:
 1457             case VK_CODE_INPUT:
 1458             case VK_JAPANESE_KATAKANA:
 1459             case VK_JAPANESE_HIRAGANA:
 1460             case VK_JAPANESE_ROMAN:
 1461             case VK_KANA_LOCK:
 1462             case VK_INPUT_METHOD_ON_OFF:
 1463   
 1464             case VK_AGAIN:
 1465             case VK_UNDO:
 1466             case VK_COPY:
 1467             case VK_PASTE:
 1468             case VK_CUT:
 1469             case VK_FIND:
 1470             case VK_PROPS:
 1471             case VK_STOP:
 1472   
 1473             case VK_HELP:
 1474             case VK_WINDOWS:
 1475             case VK_CONTEXT_MENU:
 1476                 return true;
 1477           }
 1478           return false;
 1479       }
 1480   
 1481       /**
 1482        * Returns a parameter string identifying this event.
 1483        * This method is useful for event logging and for debugging.
 1484        *
 1485        * @return a string identifying the event and its attributes
 1486        */
 1487       public String paramString() {
 1488           StringBuilder str = new StringBuilder(100);
 1489   
 1490           switch (id) {
 1491             case KEY_PRESSED:
 1492               str.append("KEY_PRESSED");
 1493               break;
 1494             case KEY_RELEASED:
 1495               str.append("KEY_RELEASED");
 1496               break;
 1497             case KEY_TYPED:
 1498               str.append("KEY_TYPED");
 1499               break;
 1500             default:
 1501               str.append("unknown type");
 1502               break;
 1503           }
 1504   
 1505           str.append(",keyCode=").append(keyCode);
 1506           str.append(",keyText=").append(getKeyText(keyCode));
 1507   
 1508           /* Some keychars don't print well, e.g. escape, backspace,
 1509            * tab, return, delete, cancel.  Get keyText for the keyCode
 1510            * instead of the keyChar.
 1511            */
 1512           str.append(",keyChar=");
 1513           switch (keyChar) {
 1514             case '\b':
 1515               str.append(getKeyText(VK_BACK_SPACE));
 1516               break;
 1517             case '\t':
 1518               str.append(getKeyText(VK_TAB));
 1519               break;
 1520             case '\n':
 1521               str.append(getKeyText(VK_ENTER));
 1522               break;
 1523             case '\u0018':
 1524               str.append(getKeyText(VK_CANCEL));
 1525               break;
 1526             case '\u001b':
 1527               str.append(getKeyText(VK_ESCAPE));
 1528               break;
 1529             case '\u007f':
 1530               str.append(getKeyText(VK_DELETE));
 1531               break;
 1532             case CHAR_UNDEFINED:
 1533               str.append(Toolkit.getProperty("AWT.undefined", "Undefined"));
 1534               str.append(" keyChar");
 1535               break;
 1536             default:
 1537               str.append("'").append(keyChar).append("'");
 1538               break;
 1539           }
 1540   
 1541           if (getModifiers() != 0) {
 1542               str.append(",modifiers=").append(getKeyModifiersText(modifiers));
 1543           }
 1544           if (getModifiersEx() != 0) {
 1545               str.append(",extModifiers=").append(getModifiersExText(modifiers));
 1546           }
 1547   
 1548           str.append(",keyLocation=");
 1549           switch (keyLocation) {
 1550             case KEY_LOCATION_UNKNOWN:
 1551               str.append("KEY_LOCATION_UNKNOWN");
 1552               break;
 1553             case KEY_LOCATION_STANDARD:
 1554               str.append("KEY_LOCATION_STANDARD");
 1555               break;
 1556             case KEY_LOCATION_LEFT:
 1557               str.append("KEY_LOCATION_LEFT");
 1558               break;
 1559             case KEY_LOCATION_RIGHT:
 1560               str.append("KEY_LOCATION_RIGHT");
 1561               break;
 1562             case KEY_LOCATION_NUMPAD:
 1563               str.append("KEY_LOCATION_NUMPAD");
 1564               break;
 1565             default:
 1566               str.append("KEY_LOCATION_UNKNOWN");
 1567               break;
 1568           }
 1569           str.append(",rawCode=").append(rawCode);
 1570           str.append(",primaryLevelUnicode=").append(primaryLevelUnicode);
 1571           str.append(",scancode=").append(scancode);
 1572           str.append(",extendedKeyCode=0x").append(Long.toHexString(extendedKeyCode));
 1573   
 1574           return str.toString();
 1575       }
 1576       /**
 1577        * Returns an extended key code for the event.
 1578        * The extended key code is a unique id assigned to  a key on the keyboard
 1579        * just like {@code keyCode}. However, unlike {@code keyCode}, this value depends on the
 1580        * current keyboard layout. For instance, pressing the left topmost letter key
 1581        * in a common English layout produces the same value as {@code keyCode}, {@code VK_Q}.
 1582        * Pressing the same key in a regular Russian layout gives another code, unique for the
 1583        * letter "Cyrillic I short".
 1584        *
 1585        * @since 1.7
 1586        *
 1587        */
 1588       public  int getExtendedKeyCode() {
 1589           return (int)extendedKeyCode;
 1590       }
 1591       /**
 1592        * Returns an extended key code for a unicode character.
 1593        *
 1594        * @return for a unicode character with a corresponding {@code VK_} constant -- this
 1595        *   {@code VK_} constant; for a character appearing on the primary
 1596        *   level of a known keyboard layout -- a unique integer.
 1597        *   If a character does not appear on the primary level of a known keyboard,
 1598        *   {@code VK_UNDEFINED} is returned.
 1599        *
 1600        * @since 1.7
 1601        *
 1602        */
 1603       public static int getExtendedKeyCodeForChar(int c) {
 1604           // Return a keycode (if any) associated with a character.
 1605           return sun.awt.ExtendedKeyCodes.getExtendedKeyCodeForChar(c);
 1606       }
 1607   
 1608       /**
 1609        * Sets new modifiers by the old ones. The key modifiers
 1610        * override overlaping mouse modifiers.
 1611        */
 1612       private void setNewModifiers() {
 1613           if ((modifiers & SHIFT_MASK) != 0) {
 1614               modifiers |= SHIFT_DOWN_MASK;
 1615           }
 1616           if ((modifiers & ALT_MASK) != 0) {
 1617               modifiers |= ALT_DOWN_MASK;
 1618           }
 1619           if ((modifiers & CTRL_MASK) != 0) {
 1620               modifiers |= CTRL_DOWN_MASK;
 1621           }
 1622           if ((modifiers & META_MASK) != 0) {
 1623               modifiers |= META_DOWN_MASK;
 1624           }
 1625           if ((modifiers & ALT_GRAPH_MASK) != 0) {
 1626               modifiers |= ALT_GRAPH_DOWN_MASK;
 1627           }
 1628           if ((modifiers & BUTTON1_MASK) != 0) {
 1629               modifiers |= BUTTON1_DOWN_MASK;
 1630           }
 1631       }
 1632   
 1633       /**
 1634        * Sets old modifiers by the new ones.
 1635        */
 1636       private void setOldModifiers() {
 1637           if ((modifiers & SHIFT_DOWN_MASK) != 0) {
 1638               modifiers |= SHIFT_MASK;
 1639           }
 1640           if ((modifiers & ALT_DOWN_MASK) != 0) {
 1641               modifiers |= ALT_MASK;
 1642           }
 1643           if ((modifiers & CTRL_DOWN_MASK) != 0) {
 1644               modifiers |= CTRL_MASK;
 1645           }
 1646           if ((modifiers & META_DOWN_MASK) != 0) {
 1647               modifiers |= META_MASK;
 1648           }
 1649           if ((modifiers & ALT_GRAPH_DOWN_MASK) != 0) {
 1650               modifiers |= ALT_GRAPH_MASK;
 1651           }
 1652           if ((modifiers & BUTTON1_DOWN_MASK) != 0) {
 1653               modifiers |= BUTTON1_MASK;
 1654           }
 1655       }
 1656   
 1657       /**
 1658        * Sets new modifiers by the old ones. The key modifiers
 1659        * override overlaping mouse modifiers.
 1660        * @serial
 1661        */
 1662       private void readObject(ObjectInputStream s)
 1663         throws IOException, ClassNotFoundException {
 1664           s.defaultReadObject();
 1665           if (getModifiers() != 0 && getModifiersEx() == 0) {
 1666               setNewModifiers();
 1667           }
 1668       }
 1669   }

Home » openjdk-7 » java » awt » event » [javadoc | source]