1 7 package javax.swing; 8 9 import java.awt.AWTKeyStroke ; 10 import java.awt.event.KeyEvent ; 11 12 47 public class KeyStroke extends AWTKeyStroke { 48 49 52 private static final long serialVersionUID = -9060180771037902530L; 53 54 private KeyStroke() { 55 } 56 private KeyStroke(char keyChar, int keyCode, int modifiers, 57 boolean onKeyRelease) { 58 super(keyChar, keyCode, modifiers, onKeyRelease); 59 } 60 61 69 public static KeyStroke getKeyStroke(char keyChar) { 70 synchronized (AWTKeyStroke .class) { 71 registerSubclass(KeyStroke .class); 72 return (KeyStroke )getAWTKeyStroke(keyChar); 73 } 74 } 75 76 88 @Deprecated  89 public static KeyStroke getKeyStroke(char keyChar, boolean onKeyRelease) { 90 return new KeyStroke (keyChar, KeyEvent.VK_UNDEFINED, 0, onKeyRelease); 91 } 92 93 117 public static KeyStroke getKeyStroke(Character keyChar, int modifiers) { 118 synchronized (AWTKeyStroke .class) { 119 registerSubclass(KeyStroke .class); 120 return (KeyStroke )getAWTKeyStroke(keyChar, modifiers); 121 } 122 } 123 124 154 public static KeyStroke getKeyStroke(int keyCode, int modifiers, 155 boolean onKeyRelease) { 156 synchronized (AWTKeyStroke .class) { 157 registerSubclass(KeyStroke .class); 158 return (KeyStroke )getAWTKeyStroke(keyCode, modifiers, 159 onKeyRelease); 160 } 161 } 162 163 190 public static KeyStroke getKeyStroke(int keyCode, int modifiers) { 191 synchronized (AWTKeyStroke .class) { 192 registerSubclass(KeyStroke .class); 193 return (KeyStroke )getAWTKeyStroke(keyCode, modifiers); 194 } 195 } 196 197 209 public static KeyStroke getKeyStrokeForEvent(KeyEvent anEvent) { 210 synchronized (AWTKeyStroke .class) { 211 registerSubclass(KeyStroke .class); 212 return (KeyStroke )getAWTKeyStrokeForEvent(anEvent); 213 } 214 } 215 216 245 public static KeyStroke getKeyStroke(String s) { 246 if (s == null || s.length() == 0) { 247 return null; 248 } 249 synchronized (AWTKeyStroke .class) { 250 registerSubclass(KeyStroke .class); 251 try { 252 return (KeyStroke )getAWTKeyStroke(s); 253 } catch (IllegalArgumentException e) { 254 return null; 255 } 256 } 257 } 258 } 259 | Popular Tags |