java.lang.Object | ||||
↳ | java.awt.Component | |||
↳ | java.awt.Container | |||
↳ | javax.swing.JComponent | |||
↳ | javax.swing.JSplitPane |
JSplitPane
is used to divide two (and only two)
Component
s. The two Component
s
are graphically divided based on the look and feel
implementation, and the two Component
s 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 Component
s 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 Component
s
is to invoke
setDividerLocation
where location
is either
the new x or y position, depending on the orientation of the
JSplitPane
.
To resize the Component
s to their preferred sizes invoke
resetToPreferredSizes
.
When the user is resizing the Component
s the minimum
size of the Components
is used to determine the
maximum/minimum position the Component
s
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 setMinimumSize(Dimension)
.
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 JavaBeansTM
has been added to the java.beans
package.
Please see XMLEncoder
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
JSplitPane.AccessibleJSplitPane | This class implements accessibility support for the
JSplitPane class. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | BOTTOM | Used to add a Component below the other
Component . |
|||||||||
String | CONTINUOUS_LAYOUT_PROPERTY | Bound property name for continuousLayout. | |||||||||
String | DIVIDER | Used to add a Component that will represent the divider. |
|||||||||
String | DIVIDER_LOCATION_PROPERTY | Bound property for the dividerLocation. | |||||||||
String | DIVIDER_SIZE_PROPERTY | Bound property name for border. | |||||||||
int | HORIZONTAL_SPLIT | Horizontal split indicates the Component s are
split along the x axis. |
|||||||||
String | LAST_DIVIDER_LOCATION_PROPERTY | Bound property for lastLocation. | |||||||||
String | LEFT | Used to add a Component to the left of the other
Component . |
|||||||||
String | ONE_TOUCH_EXPANDABLE_PROPERTY | Bound property for oneTouchExpandable. | |||||||||
String | ORIENTATION_PROPERTY | Bound property name for orientation (horizontal or vertical). | |||||||||
String | RESIZE_WEIGHT_PROPERTY | Bound property for weight. | |||||||||
String | RIGHT | Used to add a Component to the right of the other
Component . |
|||||||||
String | TOP | Used to add a Component above the other
Component . |
|||||||||
int | VERTICAL_SPLIT | Vertical split indicates the Component s are
split along the y axis. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
continuousLayout | Whether or not the views are continuously redisplayed while resizing. | ||||||||||
dividerSize | Size of the divider. | ||||||||||
lastDividerLocation | Previous location of the split pane. | ||||||||||
leftComponent | The left or top component. | ||||||||||
oneTouchExpandable | Is a little widget provided to quickly expand/collapse the split pane? | ||||||||||
orientation | How the views are split. | ||||||||||
rightComponent | The right or bottom component. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new
JSplitPane configured to arrange the child
components side-by-side horizontally with no continuous
layout, using two buttons for the components. | |||||||||||
Creates a new
JSplitPane configured with the
specified orientation and no continuous layout. | |||||||||||
Creates a new
JSplitPane with the specified
orientation and redrawing style. | |||||||||||
Creates a new
JSplitPane with the specified
orientation and
with the specified components that do not do continuous
redrawing. | |||||||||||
Creates a new
JSplitPane with the specified
orientation and
redrawing style, and with the specified components. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the AccessibleContext associated with this JSplitPane.
| |||||||||||
Returns the component below, or to the right of the divider.
| |||||||||||
Returns the last value passed to
setDividerLocation . | |||||||||||
Returns the size of the divider.
| |||||||||||
Returns the last location the divider was at.
| |||||||||||
Returns the component to the left (or above) the divider.
| |||||||||||
Returns the maximum location of the divider from the look and feel
implementation.
| |||||||||||
Returns the minimum location of the divider from the look and feel
implementation.
| |||||||||||
Returns the orientation.
| |||||||||||
Returns the number that determines how extra space is distributed.
| |||||||||||
Returns the component to the right (or below) the divider.
| |||||||||||
Returns the component above, or to the left of the divider.
| |||||||||||
Returns the
SplitPaneUI that is providing the
current look and feel. | |||||||||||
Returns the name of the L&F class that renders this component.
| |||||||||||
Gets the
continuousLayout property. | |||||||||||
Gets the
oneTouchExpandable property. | |||||||||||
Returns true, so that calls to
revalidate
on any descendant of this JSplitPane
will cause a request to be queued that
will validate the JSplitPane and all its descendants. | |||||||||||
Removes the child component,
component from the
pane. | |||||||||||
Removes the
Component at the specified index. | |||||||||||
Removes all the child components from the split pane.
| |||||||||||
Lays out the
JSplitPane layout based on the preferred size
of the children components. | |||||||||||
Sets the component below, or to the right of the divider.
| |||||||||||
Sets the value of the
continuousLayout property,
which must be true for the child components
to be continuously
redisplayed and laid out during user intervention. | |||||||||||
Sets the location of the divider.
| |||||||||||
Sets the divider location as a percentage of the
JSplitPane 's size. | |||||||||||
Sets the size of the divider.
| |||||||||||
Sets the last location the divider was at to
newLastLocation . | |||||||||||
Sets the component to the left (or above) the divider.
| |||||||||||
Sets the value of the
oneTouchExpandable property,
which must be true for the
JSplitPane to provide a UI widget
on the divider to quickly expand/collapse the divider. | |||||||||||
Sets the orientation, or how the splitter is divided.
| |||||||||||
Specifies how to distribute extra space when the size of the split pane
changes.
| |||||||||||
Sets the component to the right (or below) the divider.
| |||||||||||
Sets the component above, or to the left of the divider.
| |||||||||||
Sets the L&F object that renders this component.
| |||||||||||
Notification from the
UIManager that the L&F has changed. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds the specified component to this split pane.
| |||||||||||
Subclassed to message the UI with
finishedPaintingChildren
after super has been messaged, as well as painting the border. | |||||||||||
Returns a string representation of this
JSplitPane . |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Used to add a Component
below the other
Component
.
Bound property name for continuousLayout.
Used to add a Component
that will represent the divider.
Bound property for the dividerLocation.
Bound property name for border.
Horizontal split indicates the Component
s are
split along the x axis. For example the two
Component
s will be split one to the left of the
other.
Bound property for lastLocation.
Used to add a Component
to the left of the other
Component
.
Bound property for oneTouchExpandable.
Bound property name for orientation (horizontal or vertical).
Bound property for weight.
Used to add a Component
to the right of the other
Component
.
Used to add a Component
above the other
Component
.
Vertical split indicates the Component
s are
split along the y axis. For example the two
Component
s will be split one on top of the other.
Whether or not the views are continuously redisplayed while resizing.
Size of the divider.
Previous location of the split pane.
Is a little widget provided to quickly expand/collapse the split pane?
How the views are split.
Creates a new JSplitPane
configured to arrange the child
components side-by-side horizontally with no continuous
layout, using two buttons for the components.
Creates a new JSplitPane
configured with the
specified orientation and no continuous layout.
newOrientation | JSplitPane.HORIZONTAL_SPLIT or
JSplitPane.VERTICAL_SPLIT |
---|
IllegalArgumentException | if orientation
is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT.
|
---|
Creates a new JSplitPane
with the specified
orientation and redrawing style.
newOrientation | JSplitPane.HORIZONTAL_SPLIT or
JSplitPane.VERTICAL_SPLIT |
---|---|
newContinuousLayout | a boolean, true for the components to redraw continuously as the divider changes position, false to wait until the divider position stops changing to redraw |
IllegalArgumentException | if orientation
is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
|
---|
Creates a new JSplitPane
with the specified
orientation and
with the specified components that do not do continuous
redrawing.
newOrientation | JSplitPane.HORIZONTAL_SPLIT or
JSplitPane.VERTICAL_SPLIT |
---|---|
newLeftComponent | the Component that will
appear on the left
of a horizontally-split pane, or at the top of a
vertically-split pane |
newRightComponent | the Component that will
appear on the right
of a horizontally-split pane, or at the bottom of a
vertically-split pane |
IllegalArgumentException | if orientation
is not one of: HORIZONTAL_SPLIT or VERTICAL_SPLIT
|
---|
Creates a new JSplitPane
with the specified
orientation and
redrawing style, and with the specified components.
newOrientation | JSplitPane.HORIZONTAL_SPLIT or
JSplitPane.VERTICAL_SPLIT |
---|---|
newContinuousLayout | a boolean, true for the components to redraw continuously as the divider changes position, false to wait until the divider position stops changing to redraw |
newLeftComponent | the Component that will
appear on the left
of a horizontally-split pane, or at the top of a
vertically-split pane |
newRightComponent | the Component that will
appear on the right
of a horizontally-split pane, or at the bottom of a
vertically-split pane |
IllegalArgumentException | if orientation
is not one of HORIZONTAL_SPLIT or VERTICAL_SPLIT
|
---|
Gets the AccessibleContext associated with this JSplitPane. For split panes, the AccessibleContext takes the form of an AccessibleJSplitPane. A new AccessibleJSplitPane instance is created if necessary.
Returns the component below, or to the right of the divider.
Component
displayed in that position
Returns the last value passed to setDividerLocation
.
The value returned from this method may differ from the actual
divider location (if setDividerLocation
was passed a
value bigger than the curent size).
Returns the size of the divider.
Returns the last location the divider was at.
Returns the component to the left (or above) the divider.
Component
displayed in that positionReturns the maximum location of the divider from the look and feel implementation.
null
Returns the minimum location of the divider from the look and feel implementation.
null
Returns the number that determines how extra space is distributed.
Returns the component to the right (or below) the divider.
Component
displayed in that position
Returns the component above, or to the left of the divider.
Component
displayed in that position
Returns the SplitPaneUI
that is providing the
current look and feel.
SplitPaneUI
object that renders this componentReturns the name of the L&F class that renders this component.
Gets the continuousLayout
property.
continuousLayout
propertyGets the oneTouchExpandable
property.
oneTouchExpandable
propertyReturns true, so that calls to revalidate
on any descendant of this JSplitPane
will cause a request to be queued that
will validate the JSplitPane
and all its descendants.
Removes the child component, component
from the
pane. Resets the leftComponent
or
rightComponent
instance variable, as necessary.
component | the Component to remove
|
---|
Removes the Component
at the specified index.
Updates the leftComponent
and rightComponent
instance variables as necessary, and then messages super.
index | an integer specifying the component to remove, where 1 specifies the left/top component and 2 specifies the bottom/right component |
---|
Removes all the child components from the split pane. Resets the
leftComonent
and rightComponent
instance variables.
Lays out the JSplitPane
layout based on the preferred size
of the children components. This will likely result in changing
the divider location.
Sets the component below, or to the right of the divider.
comp | the Component to display in that position |
---|
Sets the value of the continuousLayout
property,
which must be true
for the child components
to be continuously
redisplayed and laid out during user intervention.
The default value of this property is false
.
Some look and feels might not support continuous layout;
they will ignore this property.
newContinuousLayout | true if the components
should continuously be redrawn as the divider changes position |
---|
Sets the location of the divider. This is passed off to the
look and feel implementation, and then listeners are notified. A value
less than 0 implies the divider should be reset to a value that
attempts to honor the preferred size of the left/top component.
After notifying the listeners, the last divider location is updated,
via setLastDividerLocation
.
location | an int specifying a UI-specific value (typically a pixel count) |
---|
Sets the divider location as a percentage of the
JSplitPane
's size.
This method is implemented in terms of
setDividerLocation(int)
.
This method immediately changes the size of the split pane based on
its current size. If the split pane is not correctly realized and on
screen, this method will have no effect (new divider location will
become (current size * proportionalLocation) which is 0).
proportionalLocation | a double-precision floating point value that specifies a percentage, from zero (top/left) to 1.0 (bottom/right) |
---|
IllegalArgumentException | if the specified location is < 0 or > 1.0 |
---|
Sets the size of the divider.
newSize | an integer giving the size of the divider in pixels |
---|
Sets the last location the divider was at to
newLastLocation
.
newLastLocation | 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 |
---|
Sets the component to the left (or above) the divider.
comp | the Component to display in that position
|
---|
Sets the value of the oneTouchExpandable
property,
which must be true
for the
JSplitPane
to provide a UI widget
on the divider to quickly expand/collapse the divider.
The default value of this property is false
.
Some look and feels might not support one-touch expanding;
they will ignore this property.
newValue | true to specify that the split pane should provide a
collapse/expand widget |
---|
Sets the orientation, or how the splitter is divided. The options are:
orientation | an integer specifying the orientation |
---|
IllegalArgumentException | if orientation is not one of: HORIZONTAL_SPLIT or VERTICAL_SPLIT. |
---|
Specifies how to distribute extra space when the size of the split pane changes. A value of 0, the default, indicates the right/bottom component gets all the extra space (the left/top component acts fixed), where as a value of 1 specifies the left/top component gets all the extra space (the right/bottom component acts fixed). Specifically, the left/top component gets (weight * diff) extra space and the right/bottom component gets (1 - weight) * diff extra space.
value | as described above |
---|
IllegalArgumentException | if value is < 0 or > 1 |
---|
Sets the component to the right (or below) the divider.
comp | the Component to display in that position |
---|
Sets the component above, or to the left of the divider.
comp | the Component to display in that position |
---|
Sets the L&F object that renders this component.
ui | the SplitPaneUI L&F object |
---|
Notification from the UIManager
that the L&F has changed.
Replaces the current UI object with the latest version from the
UIManager
.
Adds the specified component to this split pane.
If constraints
identifies the left/top or
right/bottom child component, and a component with that identifier
was previously added, it will be removed and then comp
will be added in its place. If constraints
is not
one of the known identifiers the layout manager may throw an
IllegalArgumentException
.
The possible constraints objects (Strings) are:
constraints
object is null
,
the component is added in the
first available position (left/top if open, else right/bottom).comp | the component to add |
---|---|
constraints | an Object specifying the
layout constraints
(position) for this component |
index | an integer specifying the index in the container's list. |
IllegalArgumentException | if the constraints
object does not match an existing component |
---|
Subclassed to message the UI with finishedPaintingChildren
after super has been messaged, as well as painting the border.
g | the Graphics context within which to paint
|
---|
Returns a string representation of this JSplitPane
.
This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null
.
JSplitPane
.