Java JSplitPane

JSplitPane is used to divide two components. The two components are divided based on the look and feel implementation, and they can be resized by the user. 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.

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

Nested Class

Modifier and TypeClassDescription
protected classJSplitPane.AccessibleJSplitPaneThis class implements accessibility support for the JsplitPane class.

Useful Fields

Modifier and TypeFieldDescription
static StringBOTTOMIt use to add a Component below the other Component.
static StringCONTINUOUS_LAYOUT_PROPERTYBound property name for continuousLayout.
static StringDIVIDERIt uses to add a Component that will represent the divider.
static intHORIZONTAL_SPLITHorizontal split indicates the Components are split along the x axis.
protected intlastDividerLocationPrevious location of the split pane.
protected ComponentleftComponentThe left or top component.
static intVERTICAL_SPLITVertical split indicates the Components are split along the y axis.
protected ComponentrightComponentThe right or bottom component.
protected intorientationHow the views are split.

Constructors

ConstructorDescription
JSplitPane()It creates a new JsplitPane configured to arrange the child components side-by-side horizontally, using two buttons for the components.
JSplitPane(int newOrientation)It creates a new JsplitPane configured with the specified orientation.
JSplitPane(int newOrientation, boolean newContinuousLayout)It creates a new JsplitPane with the specified orientation and redrawing style.
JSplitPane(int newOrientation, boolean newContinuousLayout, Component newLeftComponent, Component newRightComponent)It creates a new JsplitPane with the specified orientation and redrawing style, and with the specified components.
JSplitPane(int newOrientation, Component newLeftComponent, Component newRightComponent)It creates a new JsplitPane with the specified orientation and the specified components.

Useful Methods

Modifier and TypeMethodDescription
protected voidaddImpl(Component comp, Object constraints, int index)It cdds the specified component to this split pane.
AccessibleContextgetAccessibleContext()It gets the AccessibleContext associated with this JSplitPane.
intgetDividerLocation()It returns the last value passed to setDividerLocation.
intgetDividerSize()It returns the size of the divider.
ComponentgetBottomComponent()It returns the component below, or to the right of the divider.
ComponentgetRightComponent()It returns the component to the right (or below) the divider.
SplitPaneUIgetUI()It returns the SplitPaneUI that is providing the current look and feel.
booleanisContinuousLayout()It gets the continuousLayout property.
booleanisOneTouchExpandable()It gets the oneTouchExpandable property.
voidsetOrientation(int orientation)It gets the orientation, or how the splitter is divided.

JSplitPane Example

Output:

Java JSplitpane
Next TopicJava JTextPane




Latest Courses