JSplitPane is used to divide two (and only two)
Components. The two Components
are graphically divided based on the look and feel
implementation, and the two Components can then be
interactively resized by the user.
Information on using JSplitPane is in
How to Use Split Panes in
The Java Tutorial.
The two Components in a split pane can be aligned
left to right using
JSplitPane.HORIZONTAL_SPLIT, or top to bottom using
JSplitPane.VERTICAL_SPLIT.
The preferred way to change the size of the Components
is to invoke
setDividerLocation where location is either
the new x or y position, depending on the orientation of the
JSplitPane.
To resize the Components to their preferred sizes invoke
resetToPreferredSizes.
When the user is resizing the Components the minimum
size of the Components is used to determine the
maximum/minimum position the Components
can be set to. If the minimum size of the two
components is greater than the size of the split pane the divider
will not allow you to resize it. To alter the minimum size of a
JComponent, see JComponent#setMinimumSize.
When the user resizes the split pane the new space is distributed between
the two components based on the resizeWeight property.
A value of 0,
the default, indicates the right/bottom component gets all the space,
where as a value of 1 indicates the left/top component gets all the space.
Warning
Swing is not thread safe. For more information see Swing's Threading Policy.
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
setDividerLocation, resetToPreferredSizes
| Modifier and Type | Class and Description |
|---|---|
| protected class | JSplitPane.
This class implements accessibility support for the
|
| Modifier and Type | Field and Description |
|---|---|
| public static final String | BOTTOM
Used to add a |
| public static final String | CONTINUOUS_LAYOUT_PROPERTY
Bound property name for continuousLayout. |
| protected boolean | continuousLayout
Whether or not the views are continuously redisplayed while resizing. |
| public static final String | DIVIDER
Used to add a |
| public static final String | DIVIDER_LOCATION_PROPERTY
Bound property for the dividerLocation. |
| public static final String | DIVIDER_SIZE_PROPERTY
Bound property name for border. |
| private int | dividerLocation
Location of the divider, at least the value that was set, the UI may have a different value. |
| protected int | dividerSize
Size of the divider. |
| private boolean | |
| public static final int | HORIZONTAL_SPLIT
Horizontal split indicates the |
| public static final String | LAST_DIVIDER_LOCATION_PROPERTY
Bound property for lastLocation. |
| protected int | lastDividerLocation
Previous location of the split pane. |
| public static final String | LEFT
Used to add a |
| protected Component | leftComponent
The left or top component. |
| public static final String | ONE_TOUCH_EXPANDABLE_PROPERTY
Bound property for oneTouchExpandable. |
| protected boolean | oneTouchExpandable
Is a little widget provided to quickly expand/collapse the split pane? |
| private boolean | |
| protected int | orientation
How the views are split. |
| public static final String | ORIENTATION_PROPERTY
Bound property name for orientation (horizontal or vertical). |
| public static final String | RESIZE_WEIGHT_PROPERTY
Bound property for weight. |
| private double | resizeWeight
How to distribute extra space. |
| public static final String | RIGHT
Used to add a |
| protected Component | rightComponent
The right or bottom component. |
| public static final String | TOP
Used to add a |
| private static final String | |
| public static final int | VERTICAL_SPLIT
Vertical split indicates the |
| Access | Constructor and Description |
|---|---|
| public | JSplitPane()
Creates a new |
| public | JSplitPane(int
JSplitPane.HORIZONTAL_SPLIT or
JSplitPane.VERTICAL_SPLITCreates a new |
| public | JSplitPane(int
JSplitPane.HORIZONTAL_SPLIT or
JSplitPane.VERTICAL_SPLITa boolean, true for the components to
redraw continuously as the divider changes position, false
to wait until the divider position stops changing to redraw newContinuousLayout)Creates a new |
| public | JSplitPane(int
JSplitPane.HORIZONTAL_SPLIT or
JSplitPane.VERTICAL_SPLITthe newLeftComponent, Component Component that will
appear on the left
of a horizontally-split pane, or at the top of a
vertically-split panethe newRightComponent)Component that will
appear on the right
of a horizontally-split pane, or at the bottom of a
vertically-split paneCreates a new |
| public | JSplitPane(int
JSplitPane.HORIZONTAL_SPLIT or
JSplitPane.VERTICAL_SPLITa boolean, true for the components to
redraw continuously as the divider changes position, false
to wait until the divider position stops changing to redraw newContinuousLayout, Component the newLeftComponent, Component Component that will
appear on the left
of a horizontally-split pane, or at the top of a
vertically-split panethe newRightComponent)Component that will
appear on the right
of a horizontally-split pane, or at the bottom of a
vertically-split paneCreates a new |
| Modifier and Type | Method and Description |
|---|---|
| protected void | addImpl(Component
the component to add comp, Object an constraints, int Object specifying the
layout constraints
(position) for this componentan integer specifying the index in the container's
list. index)Overrides java. Adds the specified component to this split pane. |
| public AccessibleContext | Returns: an AccessibleJSplitPane that serves as the AccessibleContext of this JSplitPaneOverrides java. Implements javax. Gets the AccessibleContext associated with this JSplitPane. |
| public Component | Returns: theComponent displayed in that positionReturns the component below, or to the right of the divider. |
| public int | Returns: an integer specifying the location of the dividerReturns the last value passed to |
| public int | Returns: an integer giving the size of the divider in pixelsReturns the size of the divider. |
| public int | Returns: an integer specifying the last divider location as a count of pixels from the left (or upper) edge of the pane to the left (or upper) edge of the dividerReturns the last location the divider was at. |
| public Component | Returns: theComponent displayed in that positionReturns the component to the left (or above) the divider. |
| public int | Returns: an integer specifying a UI-specific value for the maximum location (typically a pixel count); or -1 if the UI isnullReturns the maximum location of the divider from the look and feel implementation. |
| public int | Returns: an integer specifying a UI-specific value for the minimum location (typically a pixel count); or -1 if the UI isnullReturns the minimum location of the divider from the look and feel implementation. |
| public int | |
| public double | Returns: how extra space is to be distributed on a resize of the split paneReturns the number that determines how extra space is distributed. |
| public Component | Returns: theComponent displayed in that positionReturns the component to the right (or below) the divider. |
| public Component | Returns: theComponent displayed in that positionReturns the component above, or to the left of the divider. |
| public SplitPaneUI | Returns: theSplitPaneUI object that renders this componentOverrides javax. Returns the |
| public String | Returns: the string "SplitPaneUI"Overrides javax. Returns the name of the L&F class that renders this component. |
| public boolean | Returns: the value of thecontinuousLayout propertyGets the |
| public boolean | Returns: the value of theoneTouchExpandable propertyGets the |
| public boolean | Returns: trueOverrides javax. Returns true, so that calls to |
| protected void | paintChildren(Graphics
the g)Graphics context within which to paintOverrides javax. Subclassed to message the UI with |
| protected String | Returns: a string representation of thisJSplitPane.Overrides javax. Returns a string representation of this |
| public void | remove(Component
the component)Component to removeOverrides java. Removes the child component, |
| public void | remove(int
an integer specifying the component to remove, where
1 specifies the left/top component and 2 specifies the
bottom/right component index)Overrides java. Removes the |
| public void | removeAll()
Overrides java. Removes all the child components from the split pane. |
| public void | resetToPreferredSizes()
Lays out the |
| public void | setBottomComponent(Component
the comp)Component to display in that positionSets the component below, or to the right of the divider. |
| public void | setComponentOrientation(ComponentOrientation orientation)
Overrides java. Sets the language-sensitive orientation that is to be used to order the elements or text within this component. |
| public void | setContinuousLayout(boolean
true if the components
should continuously be redrawn as the divider changes positionSets the value of the |
| public void | setDividerLocation(double
a double-precision floating point value
that specifies a percentage, from zero (top/left) to 1.0
(bottom/right) proportionalLocation)Sets the divider location as a percentage of the
|
| public void | setDividerLocation(int
an int specifying a UI-specific value (typically a
pixel count) location)Sets the location of the divider. |
| public void | setDividerSize(int
an integer giving the size of the divider in pixels newSize)Sets the size of the divider. |
| public void | setEnabled(boolean enabled)
Overrides javax. Sets whether or not this component is enabled. |
| public void | setLastDividerLocation(int
an integer specifying the last divider location
in pixels, from the left (or upper) edge of the pane to the
left (or upper) edge of the divider newLastLocation)Sets the last location the divider was at to
|
| public void | setLeftComponent(Component
the comp)Component to display in that positionSets the component to the left (or above) the divider. |
| public void | setOneTouchExpandable(boolean
true to specify that the split pane should provide a
collapse/expand widgetSets the value of the |
| public void | setOrientation(int
an integer specifying the orientation orientation)Sets the orientation, or how the splitter is divided. |
| public void | setResizeWeight(double
as described above value)Specifies how to distribute extra space when the size of the split pane changes. |
| public void | setRightComponent(Component
the comp)Component to display in that positionSets the component to the right (or below) the divider. |
| public void | setTopComponent(Component
the comp)Component to display in that positionSets the component above, or to the left of the divider. |
| public void | |
| pack-priv void | |
| public void | updateUI()
Overrides javax. Notification from the |
| private void | writeObject(ObjectOutputStream s)
Hides javax. See |