The Sun's API states that the attempt to set the divider location to the negative values should cause to compute the divider location from the preferred sizes. The patch makes our code to work identically.

2006-05-03  Audrius Meskauskas  <[EMAIL PROTECTED]>

   * javax/swing/JSplitPane.java (setDividerLocation(int)):
   Reset to preferred sizes if the argument is negative.

Index: JSplitPane.java
===================================================================
RCS file: /sources/classpath/classpath/javax/swing/JSplitPane.java,v
retrieving revision 1.16
diff -u -r1.16 JSplitPane.java
--- JSplitPane.java	19 Apr 2006 09:06:41 -0000	1.16
+++ JSplitPane.java	3 May 2006 18:02:02 -0000
@@ -713,16 +713,23 @@
 
   /**
    * This method sets the location of the divider.
-   *
-   * @param location The location of the divider.
+   * 
+   * @param location The location of the divider. The negative value forces to
+   *          compute the new location from the preferred sizes of the split
+   *          pane components.
    */
   public void setDividerLocation(int location)
   {
     if (ui != null && location != getDividerLocation())
       {
-        int oldLocation = getDividerLocation();
-        ((SplitPaneUI) ui).setDividerLocation(this, location);
-        firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, location);
+        int oldLocation = getDividerLocation();        
+        if (location < 0)
+          ((SplitPaneUI) ui).resetToPreferredSizes(this);
+        else
+            ((SplitPaneUI) ui).setDividerLocation(this, location);
+        
+        firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, 
+                           getDividerLocation());
       }
   }
 

Reply via email to