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

Print this page




 785                     && fields[i].getType() == Integer.TYPE
 786                     && fields[i].getName().startsWith("VK_")
 787                     && fields[i].getInt(KeyEvent.class) == keyCode)
 788                 {
 789                     name = fields[i].getName();
 790                     vkCollect.put(name, key);
 791                     return name.substring(3);
 792                 }
 793             } catch (IllegalAccessException e) {
 794                 assert(false);
 795             }
 796         }
 797         return "UNKNOWN";
 798     }
 799 
 800     /**
 801      * Returns a cached instance of <code>AWTKeyStroke</code> (or a subclass of
 802      * <code>AWTKeyStroke</code>) which is equal to this instance.
 803      *
 804      * @return a cached instance which is equal to this instance

 805      */
 806     protected Object readResolve() throws java.io.ObjectStreamException {
 807         synchronized (AWTKeyStroke.class) {
 808             if (getClass().equals(getAWTKeyStrokeClass())) {
 809                 return  getCachedStroke(keyChar, keyCode, modifiers, onKeyRelease);
 810             }
 811         }
 812         return this;
 813     }
 814 
 815     private static int mapOldModifiers(int modifiers) {
 816         if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
 817             modifiers |= InputEvent.SHIFT_DOWN_MASK;
 818         }
 819         if ((modifiers & InputEvent.ALT_MASK) != 0) {
 820             modifiers |= InputEvent.ALT_DOWN_MASK;
 821         }
 822         if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
 823             modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
 824         }




 785                     && fields[i].getType() == Integer.TYPE
 786                     && fields[i].getName().startsWith("VK_")
 787                     && fields[i].getInt(KeyEvent.class) == keyCode)
 788                 {
 789                     name = fields[i].getName();
 790                     vkCollect.put(name, key);
 791                     return name.substring(3);
 792                 }
 793             } catch (IllegalAccessException e) {
 794                 assert(false);
 795             }
 796         }
 797         return "UNKNOWN";
 798     }
 799 
 800     /**
 801      * Returns a cached instance of <code>AWTKeyStroke</code> (or a subclass of
 802      * <code>AWTKeyStroke</code>) which is equal to this instance.
 803      *
 804      * @return a cached instance which is equal to this instance
 805      * @throws java.io.ObjectStreamException if a serialization problem occurs
 806      */
 807     protected Object readResolve() throws java.io.ObjectStreamException {
 808         synchronized (AWTKeyStroke.class) {
 809             if (getClass().equals(getAWTKeyStrokeClass())) {
 810                 return  getCachedStroke(keyChar, keyCode, modifiers, onKeyRelease);
 811             }
 812         }
 813         return this;
 814     }
 815 
 816     private static int mapOldModifiers(int modifiers) {
 817         if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
 818             modifiers |= InputEvent.SHIFT_DOWN_MASK;
 819         }
 820         if ((modifiers & InputEvent.ALT_MASK) != 0) {
 821             modifiers |= InputEvent.ALT_DOWN_MASK;
 822         }
 823         if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
 824             modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
 825         }