APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

public Class JSplitPane

extends JComponent
implements Accessible
Class Inheritance
All Implemented Interfaces
javax.accessibility.Accessible
Annotations
@JavaBean
defaultProperty:UI
@SuppressWarnings:serial
Imports
java.awt.Component, .ComponentOrientation, .Graphics, java.beans.BeanProperty, .ConstructorProperties, .JavaBean, java.io.IOException, .ObjectOutputStream, .Serial, javax.accessibility.Accessible, .AccessibleContext, .AccessibleRole, .AccessibleState, .AccessibleStateSet, .AccessibleValue, javax.swing.plaf.SplitPaneUI, javax.swing.plaf.basic.BasicSplitPaneUI

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.beans.XMLEncoder.

Author
Scott Violet
Since
1.2
See Also
setDividerLocation, resetToPreferredSizes

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JSplitPane.AccessibleJSplitPane

This class implements accessibility support for the JSplitPane class.

Field Summary

Modifier and TypeField and Description
public static final String
BOTTOM

Used to add a Component below the other Component.

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 Component that will represent the divider.

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 Components are split along the x axis.

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 Component to the left of the other Component.

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 Component to the right of the other Component.

protected Component
rightComponent

The right or bottom component.

public static final String
TOP

Used to add a Component above the other Component.

private static final String
public static final int
VERTICAL_SPLIT

Vertical split indicates the Components are split along the y axis.

Inherited from javax.swing.JComponent:
DEBUG_GRAPHICS_LOADEDfocusControllerivSourceComponentlistenerListpaintingChildTOOL_TIP_TEXT_KEYuiUNDEFINED_CONDITIONWHEN_ANCESTOR_OF_FOCUSED_COMPONENTWHEN_FOCUSEDWHEN_IN_FOCUSED_WINDOW

Constructor Summary

AccessConstructor and Description
public
JSplitPane()

Creates a new JSplitPane configured to arrange the child components side-by-side horizontally, using two buttons for the components.

public
JSplitPane(int
JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT
newOrientation
)

Creates a new JSplitPane configured with the specified orientation.

public
JSplitPane(int
JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT
newOrientation
,
boolean
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
newContinuousLayout
)

Creates a new JSplitPane with the specified orientation and redrawing style.

public
JSplitPane(int
JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT
newOrientation
,
Component
the Component that will appear on the left of a horizontally-split pane, or at the top of a vertically-split pane
newLeftComponent
,
Component
the Component that will appear on the right of a horizontally-split pane, or at the bottom of a vertically-split pane
newRightComponent
)

Creates a new JSplitPane with the specified orientation and the specified components.

public
JSplitPane(int
JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT
newOrientation
,
boolean
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
newContinuousLayout
,
Component
the Component that will appear on the left of a horizontally-split pane, or at the top of a vertically-split pane
newLeftComponent
,
Component
the Component that will appear on the right of a horizontally-split pane, or at the bottom of a vertically-split pane
newRightComponent
)

Creates a new JSplitPane with the specified orientation and redrawing style, and with the specified components.

Method Summary

Modifier and TypeMethod and Description
protected void
addImpl(Component
the component to add
comp
,
Object
an Object specifying the layout constraints (position) for this component
constraints
,
int
an integer specifying the index in the container's list.
index
)

Overrides java.awt.Container.addImpl.

Adds the specified component to this split pane.

public AccessibleContext

Returns:

an AccessibleJSplitPane that serves as the AccessibleContext of this JSplitPane
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JSplitPane.

public Component

Returns:

the Component displayed in that position
getBottomComponent
()

Returns the component below, or to the right of the divider.

public int

Returns:

an integer specifying the location of the divider
getDividerLocation
()

Returns the last value passed to setDividerLocation.

public int

Returns:

an integer giving the size of the divider in pixels
getDividerSize
()

Returns 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 divider
getLastDividerLocation
()

Returns the last location the divider was at.

public Component

Returns:

the Component displayed in that position
getLeftComponent
()

Returns 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 is null
getMaximumDividerLocation
()

Returns 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 is null
getMinimumDividerLocation
()

Returns the minimum location of the divider from the look and feel implementation.

public int

Returns:

an integer giving the orientation
getOrientation
()

Returns the orientation.

public double

Returns:

how extra space is to be distributed on a resize of the split pane
getResizeWeight
()

Returns the number that determines how extra space is distributed.

public Component

Returns:

the Component displayed in that position
getRightComponent
()

Returns the component to the right (or below) the divider.

public Component

Returns:

the Component displayed in that position
getTopComponent
()

Returns the component above, or to the left of the divider.

public SplitPaneUI

Returns:

the SplitPaneUI object that renders this component
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the SplitPaneUI that is providing the current look and feel.

public String

Returns:

the string "SplitPaneUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the L&F class that renders this component.

public boolean

Returns:

the value of the continuousLayout property
isContinuousLayout
()

Gets the continuousLayout property.

public boolean

Returns:

the value of the oneTouchExpandable property
isOneTouchExpandable
()

Gets the oneTouchExpandable property.

public boolean

Returns:

true
isValidateRoot
()

Overrides javax.swing.JComponent.isValidateRoot.

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.

protected void
paintChildren(Graphics
the Graphics context within which to paint
g
)

Overrides javax.swing.JComponent.paintChildren.

Subclassed to message the UI with finishedPaintingChildren after super has been messaged, as well as painting the border.

protected String

Returns:

a string representation of this JSplitPane.
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JSplitPane.

public void
remove(Component
the Component to remove
component
)

Overrides java.awt.Container.remove.

Removes the child component, component from the pane.

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.awt.Container.remove.

Removes the Component at the specified index.

public void
removeAll()

Overrides java.awt.Container.removeAll.

Removes all the child components from the split pane.

public void
resetToPreferredSizes()

Lays out the JSplitPane layout based on the preferred size of the children components.

public void
setBottomComponent(Component
the Component to display in that position
comp
)

Sets the component below, or to the right of the divider.

public void
setComponentOrientation(ComponentOrientation orientation)

Overrides java.awt.Component.setComponentOrientation.

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 position
newContinuousLayout
)

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.

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 JSplitPane's size.

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.swing.JComponent.setEnabled.

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 newLastLocation.

public void
setLeftComponent(Component
the Component to display in that position
comp
)

Sets 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 widget
newValue
)

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.

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 Component to display in that position
comp
)

Sets the component to the right (or below) the divider.

public void
setTopComponent(Component
the Component to display in that position
comp
)

Sets the component above, or to the left of the divider.

public void
setUI(SplitPaneUI
the SplitPaneUI L&F object
ui
)

Sets the L&F object that renders this component.

pack-priv void
public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Notification from the UIManager that the L&F has changed.

private void
writeObject(ObjectOutputStream s)

Hides javax.swing.JComponent.writeObject.

See readObject and writeObject in JComponent for more information about serialization in Swing.

Inherited from javax.swing.JComponent:
_paintImmediatelyaddAncestorListeneraddNotifyaddVetoableChangeListeneralwaysOnTopcheckIfChildObscuredBySiblingclientPropertyChangedcomponentInputMapChangedcomputeVisibleRectcomputeVisibleRectcompWriteObjectNotifycontainscreateToolTipdisabledndDonedropLocationForPointenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetCreatedDoubleBuffergetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetGraphicsInvokedgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetManagingFocusBackwardTraversalKeysgetManagingFocusForwardTraversalKeysgetMaximumSizegetMinimumSizegetNextFocusableComponentgetPopupLocationgetPreferredSizegetRegisteredKeyStrokesgetRootPanegetSizegetToolTipLocationgetToolTipTextgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetWriteObjCountergetXgetYgrabFocushideisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisOptimizedDrawingEnabledisPaintingisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledpaintpaintBorderpaintComponentpaintForceDoubleBufferedpaintImmediatelypaintImmediatelypaintToOffscreenprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingprocessKeyBindingsprocessKeyBindingsForAllComponentsprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyrectangleIsObscuredregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveNotifyremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsreshaperevalidatesafelyGetGraphicssafelyGetGraphicsscrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetCreatedDoubleBuffersetDebugGraphicsOptionssetDefaultLocalesetDoubleBufferedsetDropLocationsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetMaximumSizesetMinimumSizesetNextFocusableComponentsetOpaquesetPaintingChildsetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetVerifyInputWhenFocusTargetsetVisiblesetWriteObjCountershouldDebugGraphicssuperProcessMouseMotionEventunregisterKeyboardActionupdate