This patch (committed) adds an argument check to two methods in the AbstractButton class:

2006-07-07  David Gilbert  <[EMAIL PROTECTED]>

        * javax/swing/AbstractButton.java
        (setHorizontalAlignment): Check for illegal argument,
        (setVerticalAlignment): Likewise.

Mauve tests to follow.

Regards,

Dave
Index: javax/swing/AbstractButton.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/AbstractButton.java,v
retrieving revision 1.62
diff -u -r1.62 AbstractButton.java
--- javax/swing/AbstractButton.java     7 Jul 2006 15:32:55 -0000       1.62
+++ javax/swing/AbstractButton.java     7 Jul 2006 16:01:28 -0000
@@ -1297,9 +1297,11 @@
    * alignment is a numeric constant from [EMAIL PROTECTED] SwingConstants}. 
It must
    * be one of: <code>RIGHT</code>, <code>LEFT</code>, <code>CENTER</code>,
    * <code>LEADING</code> or <code>TRAILING</code>.  The default is
-   * <code>RIGHT</code>.
+   * <code>CENTER</code>.
    * 
    * @return The current horizontal alignment
+   * 
+   * @see #setHorizontalAlignment(int)
    */
   public int getHorizontalAlignment()
   {
@@ -1311,17 +1313,21 @@
    * alignment is a numeric constant from [EMAIL PROTECTED] SwingConstants}. 
It must
    * be one of: <code>RIGHT</code>, <code>LEFT</code>, <code>CENTER</code>,
    * <code>LEADING</code> or <code>TRAILING</code>.  The default is
-   * <code>RIGHT</code>.
+   * <code>CENTER</code>.
    *
    * @param a The new horizontal alignment
    * @throws IllegalArgumentException If alignment is not one of the legal
    * constants.
+   * 
+   * @see #getHorizontalAlignment()
    */
   public void setHorizontalAlignment(int a)
   {
     if (horizontalAlignment == a)
       return;
-
+    if (a != LEFT && a != CENTER && a != RIGHT && a != LEADING 
+        && a != TRAILING)
+      throw new IllegalArgumentException("Invalid alignment.");
     int old = horizontalAlignment;
     horizontalAlignment = a;
     firePropertyChange(HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, old, a);
@@ -1373,6 +1379,8 @@
    * <code>BOTTOM</code>. The default is <code>CENTER</code>.
    *
    * @return The current vertical alignment
+   * 
+   * @see #setVerticalAlignment(int)
    */
   public int getVerticalAlignment()
   {
@@ -1388,12 +1396,16 @@
    * @param a The new vertical alignment
    * @throws IllegalArgumentException If alignment is not one of the legal
    * constants.
+   * 
+   * @see #getVerticalAlignment()
    */
   public void setVerticalAlignment(int a)
   {
     if (verticalAlignment == a)
       return;
-    
+    if (a != TOP && a != CENTER && a != BOTTOM)
+      throw new IllegalArgumentException("Invalid alignment.");
+
     int old = verticalAlignment;
     verticalAlignment = a;
     firePropertyChange(VERTICAL_ALIGNMENT_CHANGED_PROPERTY, old, a);

Reply via email to