This patch for JSplitPane fixes PR 24904 (sorry, forgot to put that in the ChangeLog) and makes a bunch of new Mauve tests pass (they are pasted at the bottom of this email).
Only the no-argument constructor is a "demo" constructor (this seems like a ridiculous idea in the first place, who would want this?) so it creates a JButton as the left component and a JButton as the right component. The other constructors should allow null to be passed as arguments for the components, and setLeftComponent and setRightComponent should allow null as well. The changes to BasicSplitPaneUI are just != null checks now that the components can be null. 2005-11-16 Anthony Balkissoon <[EMAIL PROTECTED]> * javax/swing/JSplitPane.java: (JSplitPane<init>): This is a "demo" constructor, should create two new JButtons, one with label "left button" and the other with label "right button." (setLeftComponent): Do not create JButtons here. A null argument is taken to mean remove the current component. (setRightComponent): Likewise. * javax/swing/plaf/basic/BasicSplitPaneUI: (setDividerLocation): Check that right component is not null before trying to get its preferred size. (startDragging): Avoid NPE by checking that left and right components are not null. --Tony ** FIXED MAUVE TESTS ** gnu.testlet.javax.swing.JSplitPane.Constructor FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with only orientation (number 1) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with only orientation (number 2) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with only orientation (number 3) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with only orientation (number 4) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and layout (number 1) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and layout (number 2) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and layout (number 3) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and layout (number 4) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and layout (number 5) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and layout (number 6) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and layout (number 7) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and layout (number 8) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and 2 components (number 1) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and 2 components (number 2) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and 2 components (number 3) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: constructor with orientation and 2 components (number 4) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: most general constructor (number 1) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: most general constructor (number 2) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: most general constructor (number 3) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: most general constructor (number 4) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: most general constructor (number 5) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: most general constructor (number 6) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: most general constructor (number 7) FAIL: gnu.testlet.javax.swing.JSplitPane.Constructor: most general constructor (number 8) gnu.testlet.javax.swing.JSplitPane.setComponent FAIL: gnu.testlet.javax.swing.JSplitPane.setComponent: set left (number 1) FAIL: gnu.testlet.javax.swing.JSplitPane.setComponent: set left (number 3) FAIL: gnu.testlet.javax.swing.JSplitPane.setComponent: set right (number 1) FAIL: gnu.testlet.javax.swing.JSplitPane.setComponent: set right (number 3)
Index: javax/swing/JSplitPane.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/JSplitPane.java,v retrieving revision 1.8 diff -u -r1.8 JSplitPane.java --- javax/swing/JSplitPane.java 19 Oct 2005 15:45:04 -0000 1.8 +++ javax/swing/JSplitPane.java 16 Nov 2005 21:34:57 -0000 @@ -286,7 +286,8 @@ */ public JSplitPane() { - this(HORIZONTAL_SPLIT, false, null, null); + this(HORIZONTAL_SPLIT, false, new JButton("left button"), + new JButton("right button")); } /** @@ -696,11 +697,11 @@ * @param comp The left component. */ public void setLeftComponent(Component comp) - { + { if (comp != null) add(comp, LEFT); else - add(new JButton("left button"), LEFT); + remove (leftComponent); } /** @@ -766,7 +767,7 @@ if (comp != null) add(comp, RIGHT); else - add(new JButton("right button"), RIGHT); + remove (rightComponent); } /** Index: javax/swing/plaf/basic/BasicSplitPaneUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicSplitPaneUI.java,v retrieving revision 1.21 diff -u -r1.21 BasicSplitPaneUI.java --- javax/swing/plaf/basic/BasicSplitPaneUI.java 11 Nov 2005 20:47:39 -0000 1.21 +++ javax/swing/plaf/basic/BasicSplitPaneUI.java 16 Nov 2005 21:34:57 -0000 @@ -1300,7 +1300,9 @@ { location = validLocation(location); Container p = jc.getParent(); - Dimension rightPrefSize = jc.getRightComponent().getPreferredSize(); + Component right = jc.getRightComponent(); + Dimension rightPrefSize = right == null ? new Dimension(0, 0) + : right.getPreferredSize(); Dimension size = jc.getSize(); // check if the size has been set for the splitpane if (size.width == 0 && size.height == 0) @@ -1483,11 +1485,13 @@ */ protected void startDragging() { + Component left = splitPane.getLeftComponent(); + Component right = splitPane.getRightComponent(); dividerSize = divider.getDividerSize(); setLastDragLocation(-1); - if (! splitPane.getLeftComponent().isLightweight() - || ! splitPane.getRightComponent().isLightweight()) + if ((left != null && !left.isLightweight()) + || (right != null && !right.isLightweight())) draggingHW = true; if (splitPane.isContinuousLayout())
_______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches