aboutsummaryrefslogtreecommitdiff
path: root/libjava/javax/swing/KeyStroke.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/javax/swing/KeyStroke.java')
-rw-r--r--libjava/javax/swing/KeyStroke.java29
1 files changed, 23 insertions, 6 deletions
diff --git a/libjava/javax/swing/KeyStroke.java b/libjava/javax/swing/KeyStroke.java
index afdbae8300a..239c8dd1f84 100644
--- a/libjava/javax/swing/KeyStroke.java
+++ b/libjava/javax/swing/KeyStroke.java
@@ -1,5 +1,5 @@
/* KeyStroke.java --
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.swing;
import java.awt.AWTKeyStroke;
@@ -45,12 +46,15 @@ public class KeyStroke
extends AWTKeyStroke
implements Serializable
{
- static final long serialVersionUID = -9060180771037902530L;
- private KeyStroke() {
+ private static final long serialVersionUID = -9060180771037902530L;
+
+ // Called by java.awt.AWTKeyStroke.registerSubclass via reflection.
+ private KeyStroke()
+ {
}
- protected KeyStroke(char keyChar, int keyCode, int modifiers,
- boolean onKeyRelease)
+ private KeyStroke(char keyChar, int keyCode, int modifiers,
+ boolean onKeyRelease)
{
super(keyChar, keyCode, modifiers, onKeyRelease);
}
@@ -92,9 +96,22 @@ public class KeyStroke
return (KeyStroke) getAWTKeyStroke(keyCode, modifiers);
}
+ /**
+ * Returns the KeyStroke according to <code>getAWTKeyStroke()</code>.
+ * But it returns null instead of throwing
+ * <code>IllegalArugmentException</code> when
+ * the keystoke sequence cannot be parsed from the given string.
+ */
public static KeyStroke getKeyStroke(String str)
{
- return (KeyStroke) getAWTKeyStroke(str);
+ try
+ {
+ return (KeyStroke) getAWTKeyStroke(str);
+ }
+ catch (IllegalArgumentException iae)
+ {
+ return null;
+ }
}
public static KeyStroke getKeyStrokeForEvent(KeyEvent event)