I checked SpinnerDateModel and it doesn't have the same problem, but I committed Mauve test cases in any case.

Regards,

Dave


David Gilbert wrote:

The getNextValue() and getPreviousValue() methods in the SpinnerNumberModel throw a NullPointerException if the maximum / minimum values are not set. This patch (committed) prevents that from happening:

2006-02-15  David Gilbert  <[EMAIL PROTECTED]>

    * javax/swing/SpinnerNumberModel.java
    (getNextValue): Check for null maximum,
    (getPreviousValue): Check for null minimum.

I've already committed Mauve tests to cover these cases, and will now go and check SpinnerDateModel to see if it has the same problem...

Regards,

Dave

------------------------------------------------------------------------

Index: javax/swing/SpinnerNumberModel.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/SpinnerNumberModel.java,v
retrieving revision 1.10
diff -u -r1.10 SpinnerNumberModel.java
--- javax/swing/SpinnerNumberModel.java 9 Feb 2006 22:45:01 -0000       1.10
+++ javax/swing/SpinnerNumberModel.java 15 Feb 2006 10:53:25 -0000
@@ -204,8 +204,12 @@
      num = new Short((short) (value.shortValue() + stepSize.shortValue()));
    else
      num = new Byte((byte) (value.byteValue() + stepSize.byteValue()));
-
-    return maximum.compareTo(num) >= 0 ? num : null;
+ + // check upper bound if set
+    if ((maximum != null) && maximum.compareTo(num) < 0)
+      num = null;
+ + return num;
  }

  /**
@@ -232,8 +236,12 @@
      num = new Short((short) (value.shortValue() - stepSize.shortValue()));
    else
      num = new Byte((byte) (value.byteValue() - stepSize.byteValue()));
+ + // check lower bound if set
+    if ((minimum != null) && minimum.compareTo(num) > 0)
+      num = null;

-    return minimum.compareTo(num) <= 0 ? num : null;
+    return num;
  }

  /**


Reply via email to