< prev index next >

src/java.desktop/share/classes/java/awt/AWTKeyStroke.java

Print this page


   1 /*
   2  * Copyright (c) 2000, 2014, 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


  73     private static VKCollection vks;
  74 
  75     //A key for the collection of AWTKeyStrokes within AppContext.
  76     private static Object APP_CONTEXT_CACHE_KEY = new Object();
  77     //A key withing the cache
  78     private static AWTKeyStroke APP_CONTEXT_KEYSTROKE_KEY = new AWTKeyStroke();
  79 
  80     private char keyChar = KeyEvent.CHAR_UNDEFINED;
  81     private int keyCode = KeyEvent.VK_UNDEFINED;
  82     private int modifiers;
  83     private boolean onKeyRelease;
  84 
  85     static {
  86         /* ensure that the necessary native libraries are loaded */
  87         Toolkit.loadLibraries();
  88     }
  89 
  90     /**
  91      * Constructs an {@code AWTKeyStroke} with default values.
  92      * The default values used are:
  93      * <table border="1" summary="AWTKeyStroke default values">



  94      * <tr><th>Property</th><th>Default Value</th></tr>


  95      * <tr>
  96      *    <td>Key Char</td>
  97      *    <td>{@code KeyEvent.CHAR_UNDEFINED}</td>
  98      * </tr>
  99      * <tr>
 100      *    <td>Key Code</td>
 101      *    <td>{@code KeyEvent.VK_UNDEFINED}</td>
 102      * </tr>
 103      * <tr>
 104      *    <td>Modifiers</td>
 105      *    <td>none</td>
 106      * </tr>
 107      * <tr>
 108      *    <td>On key release?</td>
 109      *    <td>{@code false}</td>
 110      * </tr>

 111      * </table>
 112      *
 113      * {@code AWTKeyStroke}s should not be constructed
 114      * by client code. Use a variant of {@code getAWTKeyStroke}
 115      * instead.
 116      *
 117      * @see #getAWTKeyStroke
 118      */
 119     protected AWTKeyStroke() {
 120     }
 121 
 122     /**
 123      * Constructs an {@code AWTKeyStroke} with the specified
 124      * values. {@code AWTKeyStroke}s should not be constructed
 125      * by client code. Use a variant of {@code getAWTKeyStroke}
 126      * instead.
 127      *
 128      * @param keyChar the character value for a keyboard key
 129      * @param keyCode the key code for this {@code AWTKeyStroke}
 130      * @param modifiers a bitwise-ored combination of any modifiers


   1 /*
   2  * Copyright (c) 2000, 2017, 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


  73     private static VKCollection vks;
  74 
  75     //A key for the collection of AWTKeyStrokes within AppContext.
  76     private static Object APP_CONTEXT_CACHE_KEY = new Object();
  77     //A key withing the cache
  78     private static AWTKeyStroke APP_CONTEXT_KEYSTROKE_KEY = new AWTKeyStroke();
  79 
  80     private char keyChar = KeyEvent.CHAR_UNDEFINED;
  81     private int keyCode = KeyEvent.VK_UNDEFINED;
  82     private int modifiers;
  83     private boolean onKeyRelease;
  84 
  85     static {
  86         /* ensure that the necessary native libraries are loaded */
  87         Toolkit.loadLibraries();
  88     }
  89 
  90     /**
  91      * Constructs an {@code AWTKeyStroke} with default values.
  92      * The default values used are:
  93      *
  94      * <table class="striped">
  95      * <caption>AWTKeyStroke default values</caption>
  96      * <thead>
  97      * <tr><th>Property</th><th>Default Value</th></tr>
  98      * </thead>
  99      * <tbody>
 100      * <tr>
 101      *    <td>Key Char</td>
 102      *    <td>{@code KeyEvent.CHAR_UNDEFINED}</td>
 103      * </tr>
 104      * <tr>
 105      *    <td>Key Code</td>
 106      *    <td>{@code KeyEvent.VK_UNDEFINED}</td>
 107      * </tr>
 108      * <tr>
 109      *    <td>Modifiers</td>
 110      *    <td>none</td>
 111      * </tr>
 112      * <tr>
 113      *    <td>On key release?</td>
 114      *    <td>{@code false}</td>
 115      * </tr>
 116      * </tbody>
 117      * </table>
 118      *
 119      * {@code AWTKeyStroke}s should not be constructed
 120      * by client code. Use a variant of {@code getAWTKeyStroke}
 121      * instead.
 122      *
 123      * @see #getAWTKeyStroke
 124      */
 125     protected AWTKeyStroke() {
 126     }
 127 
 128     /**
 129      * Constructs an {@code AWTKeyStroke} with the specified
 130      * values. {@code AWTKeyStroke}s should not be constructed
 131      * by client code. Use a variant of {@code getAWTKeyStroke}
 132      * instead.
 133      *
 134      * @param keyChar the character value for a keyboard key
 135      * @param keyCode the key code for this {@code AWTKeyStroke}
 136      * @param modifiers a bitwise-ored combination of any modifiers


< prev index next >