Here comes another fix for JSplitPane which should make it somewhat
useable again.

2006-01-25  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/JSplitPane.java
        (addImpl): Call resetToPreferredSizes() when no dividerLocation
        has been set in order to set an initial layout.
        * javax/swing/plaf/basic/BasicSplitPaneUI.java
        (BasicHorizontalLayoutManager.layoutContainer): Fixed error for
        layout of the right component.
        (BasicHorizontalLayoutManager.resetToPreferredSizes): Set the
        dividerLocation to the size of the left component.
        (createDefaultNonContinuousLayoutDivider): Fetch the color from
        the UIManager.
        (setDividerLocation): Don't validate the location here. Sometimes
        the divider needs to be set to an invalid location.
        (startDragging): Don't revalidate and repaint here.
        (finishDraggingTo): Don't repaint here. Also, don't call
        dragDividerTo() here.
        * javax/swing/plaf/basic/BasicLookAndFeel.java
        (initComponentDefaults): Added SplitPaneDivider.draggingColor
        default value.


/Roman
Index: javax/swing/JSplitPane.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JSplitPane.java,v
retrieving revision 1.11
diff -u -r1.11 JSplitPane.java
--- javax/swing/JSplitPane.java	25 Jan 2006 11:17:17 -0000	1.11
+++ javax/swing/JSplitPane.java	25 Jan 2006 14:47:36 -0000
@@ -343,6 +343,11 @@
           throw new 
             IllegalArgumentException("Constraints is not a known identifier.");
 
+        // If no dividerLocation has been set, then we need to trigger an
+        // initial layout.
+        if (getDividerLocation() != -1)
+          resetToPreferredSizes();
+
         super.addImpl(comp, constraints, index);
       }
   }
Index: javax/swing/plaf/basic/BasicLookAndFeel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicLookAndFeel.java,v
retrieving revision 1.83
diff -u -r1.83 BasicLookAndFeel.java
--- javax/swing/plaf/basic/BasicLookAndFeel.java	21 Jan 2006 22:49:47 -0000	1.83
+++ javax/swing/plaf/basic/BasicLookAndFeel.java	25 Jan 2006 14:47:36 -0000
@@ -1024,6 +1024,7 @@
       "SplitPane.highlight", new ColorUIResource(highLight),
       "SplitPane.shadow", new ColorUIResource(shadow),
       "SplitPaneDivider.border", BasicBorders.getSplitPaneDividerBorder(),
+      "SplitPaneDivider.draggingColor", new ColorUIResource(Color.DARK_GRAY),
       "TabbedPane.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
         "ctrl PAGE_DOWN","navigatePageDown",
         "ctrl PAGE_UP", "navigatePageUp",
Index: javax/swing/plaf/basic/BasicSplitPaneUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java,v
retrieving revision 1.25
diff -u -r1.25 BasicSplitPaneUI.java
--- javax/swing/plaf/basic/BasicSplitPaneUI.java	25 Jan 2006 11:17:17 -0000	1.25
+++ javax/swing/plaf/basic/BasicSplitPaneUI.java	25 Jan 2006 14:47:36 -0000
@@ -258,7 +258,7 @@
           int loc = getInitialLocation(insets);
           int available = getAvailableSize(dims, insets);
           sizes[0] = getDividerLocation(split) - loc;
-          sizes[1] = available - sizes[0] - sizes[1];
+          sizes[1] = available - sizes[0] - sizes[2];
           // The size of the divider won't change.
 
           // Layout component#1.
@@ -390,6 +390,8 @@
     {
       for (int i = 0; i < components.length; i++)
         resetSizeAt(i);
+      setDividerLocation(splitPane,
+                         getInitialLocation(splitPane.getInsets()) + sizes[0]);
     }
 
     /**
@@ -1210,7 +1212,8 @@
     if (nonContinuousLayoutDivider == null)
       {
         nonContinuousLayoutDivider = new Canvas();
-        nonContinuousLayoutDivider.setBackground(Color.DARK_GRAY);
+        Color c = UIManager.getColor("SplitPaneDivider.draggingColor");
+        nonContinuousLayoutDivider.setBackground(c);
       }
     return nonContinuousLayoutDivider;
   }
@@ -1289,7 +1292,7 @@
    */
   public void setDividerLocation(JSplitPane jc, int location)
   {
-    dividerLocation = validLocation(location);
+    dividerLocation = location;
     splitPane.revalidate();
     splitPane.repaint();
   }
@@ -1454,8 +1457,6 @@
         nonContinuousLayoutDivider.setVisible(true);
         nonContinuousLayoutDivider.setBounds(divider.getBounds());
       }
-    splitPane.revalidate();
-    splitPane.repaint();
   }
 
   /**
@@ -1497,11 +1498,9 @@
       nonContinuousLayoutDivider.setVisible(false);
     draggingHW = false;
     location = validLocation(location);
-    dragDividerTo(location);
     splitPane.setDividerLocation(location);
     splitPane.setLastDividerLocation(beginDragDividerLocation);
     beginDragDividerLocation = -1;
-    splitPane.repaint();
   }
 
   /**
_______________________________________________
Classpath-patches mailing list
[email protected]
http://developer.classpath.org/mailman/listinfo/classpath-patches

Reply via email to