/[classpath]/classpath/java/awt/AWTKeyStroke.java
ViewVC logotype

Diff of /classpath/java/awt/AWTKeyStroke.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5.2.2 by gnu_andrew, Fri Jan 14 10:24:14 2005 UTC revision 1.5.2.3 by gnu_andrew, Wed Feb 16 01:11:42 2005 UTC
# Line 397  public class AWTKeyStroke implements Ser Line 397  public class AWTKeyStroke implements Ser
397     * </code>           * </code>      
398     *     *
399     * @param s the string to parse     * @param s the string to parse
400       * @throws IllegalArgumentException if s is null or cannot be parsed
401     * @return the specified keystroke     * @return the specified keystroke
    * @throws NullPointerException if s is null  
    * @throws IllegalArgumentException if s cannot be parsed  
402     */     */
403    public static AWTKeyStroke getAWTKeyStroke(String s)    public static AWTKeyStroke getAWTKeyStroke(String s)
404    {    {
405        if (s == null)
406          throw new IllegalArgumentException("null argument");
407      StringTokenizer t = new StringTokenizer(s, " ");      StringTokenizer t = new StringTokenizer(s, " ");
408      if (! t.hasMoreTokens())      if (! t.hasMoreTokens())
409        throw new IllegalArgumentException();        throw new IllegalArgumentException("no tokens '" + s + "'");
410      int modifiers = 0;      int modifiers = 0;
411      boolean released = false;      boolean released = false;
412      String token = null;      String token = null;
# Line 436  public class AWTKeyStroke implements Ser Line 437  public class AWTKeyStroke implements Ser
437                                           KeyEvent.VK_UNDEFINED, modifiers,                                           KeyEvent.VK_UNDEFINED, modifiers,
438                                           false);                                           false);
439                }                }
440              throw new IllegalArgumentException();              throw new IllegalArgumentException("Invalid 'typed' argument '"
441                                                   + s + "'");
442            }            }
443          else if ("pressed".equals(token))          else if ("pressed".equals(token))
444            {            {
# Line 457  public class AWTKeyStroke implements Ser Line 459  public class AWTKeyStroke implements Ser
459      while (t.hasMoreTokens());      while (t.hasMoreTokens());
460      // Now token contains the VK name we must parse.      // Now token contains the VK name we must parse.
461      Integer code = (Integer) vktable.get(token);      Integer code = (Integer) vktable.get(token);
462      if (code == null || t.hasMoreTokens())      if (code == null)
463        throw new IllegalArgumentException();        throw new IllegalArgumentException("Unknown token '" + token
464                                             + "' in '" + s + "'");
465        if (t.hasMoreTokens())
466          throw new IllegalArgumentException("Too many tokens: " + s);
467      return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, code.intValue(),      return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, code.intValue(),
468                             modifiers, released);                             modifiers, released);
469    }    }

Legend:
Removed from v.1.5.2.2  
changed lines
  Added in v.1.5.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26