summaryrefslogtreecommitdiff
path: root/javax/swing/JSplitPane.java
diff options
context:
space:
mode:
Diffstat (limited to 'javax/swing/JSplitPane.java')
-rw-r--r--javax/swing/JSplitPane.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/javax/swing/JSplitPane.java b/javax/swing/JSplitPane.java
index 4e18b7cda..c11512198 100644
--- a/javax/swing/JSplitPane.java
+++ b/javax/swing/JSplitPane.java
@@ -713,16 +713,23 @@ public class JSplitPane extends JComponent implements Accessible
/**
* 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());
}
}