public class SplitPane extends Control
A control that has two or more sides, each separated by a divider, which can be dragged by the user to give more space to one of the sides, resulting in the other side shrinking by an equal amount.
Nodes
can be positioned horizontally next to each other, or stacked
vertically. This can be controlled by setting the orientationProperty()
.
The dividers in a SplitPane have the following behavior
Nodes needs to be placed inside a layout container before they are added into the SplitPane. If the node is not inside a layout container the maximum and minimum position of the divider will be the maximum and minimum size of the content.
A divider's position ranges from 0 to 1.0(inclusive). A position of 0 will place the
divider at the left/top most edge of the SplitPane plus the minimum size of the node. A
position of 1.0 will place the divider at the right/bottom most edge of the SplitPane minus the
minimum size of the node. A divider position of 0.5 will place the
the divider in the middle of the SplitPane. Setting the divider position greater
than the node's maximum size position will result in the divider being set at the
node's maximum size position. Setting the divider position less than the node's minimum size position
will result in the divider being set at the node's minimum size position. Therefore the value set in
setDividerPosition(int, double)
and setDividerPositions(double...)
may not be the same as the value returned by
getDividerPositions()
.
If there are more than two nodes in the SplitPane and the divider positions are set in such a way that the dividers cannot fit the nodes the dividers will be automatically adjusted by the SplitPane.
For example we have three nodes whose sizes and divider positions are
Node 1: min 25 max 100 Node 2: min 100 max 200 Node 3: min 25 max 50 divider 1: 0.40 divider 2: 0.45
The result will be Node 1 size will be its pref size and divider 1 will be positioned 0.40, Node 2 size will be its min size and divider 2 position will be the min size of Node 2 plus divider 1 position, and the remaining space will be given to Node 3.
SplitPane sets focusTraversable to false.
Example:
SplitPane sp = new SplitPane();
final StackPane sp1 = new StackPane();
sp1.getItems().add(new Button("Button One"));
final StackPane sp2 = new StackPane();
sp2.getItems().add(new Button("Button Two"));
final StackPane sp3 = new StackPane();
sp3.getItems().add(new Button("Button Three"));
sp.getItems().addAll(sp1, sp2, sp3);
sp.setDividerPositions(0.3f, 0.6f, 0.9f);
Type | Property and Description |
---|---|
<any> |
orientation
The orientation for the SplitPane.
|
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipProperty
Modifier and Type | Class and Description |
---|---|
static class |
SplitPane.Divider
Represents a single divider in the SplitPane.
|
private static class |
SplitPane.StyleableProperties |
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
DEFAULT_STYLE_CLASS
*
Stylesheet Handling *
*
|
private java.util.WeakHashMap<java.lang.Integer,java.lang.Double> |
dividerCache |
private <any> |
dividers |
private static PseudoClass |
HORIZONTAL_PSEUDOCLASS_STATE |
private <any> |
items
*
Instance Variables *
*
|
private <any> |
orientation
*
Properties *
*
|
private static java.lang.String |
RESIZABLE_WITH_PARENT
static methods
|
private <any> |
unmodifiableDividers |
private static PseudoClass |
VERTICAL_PSEUDOCLASS_STATE |
Constructor and Description |
---|
SplitPane()
Creates a new SplitPane with no content.
|
SplitPane(Node... items)
Creates a new SplitPane with the given items set as the content to split
between one or more dividers.
|
Modifier and Type | Method and Description |
---|---|
protected Skin<?> |
createDefaultSkin()
Create a new instance of the default skin for this control.
|
static java.util.List<<any>> |
getClassCssMetaData() |
java.util.List<<any>> |
getControlCssMetaData() |
double[] |
getDividerPositions()
Returns an array of double containing the position of each divider.
|
<any> |
getDividers()
Returns an unmodifiable list of all the dividers in this SplitPane.
|
protected java.lang.Boolean |
getInitialFocusTraversable()
Returns the initial focus traversable state of this control, for use
by the JavaFX CSS engine to correctly set its initial value.
|
<any> |
getItems()
Returns an ObservableList which can be use to modify the contents of the SplitPane.
|
Orientation |
getOrientation()
The orientation for the SplitPane.
|
static java.lang.Boolean |
isResizableWithParent(Node node)
Return true if the node is resizable when the parent container is resized false otherwise.
|
<any> |
orientationProperty()
The orientation for the SplitPane.
|
void |
setDividerPosition(int dividerIndex,
double position)
Sets the position of the divider at the specified divider index.
|
void |
setDividerPositions(double... positions)
Sets the position of the divider
|
void |
setOrientation(Orientation value)
This property controls how the SplitPane should be displayed to the
user.
|
static void |
setResizableWithParent(Node node,
java.lang.Boolean value)
Sets a node in the SplitPane to be resizable or not when the SplitPane is
resized.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getControlChildren, getCssMetaData, getSkin, getTooltip, isResizable, layoutChildren, loadSkinClass, queryAccessibleAttribute, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipProperty
public final <any> orientationProperty
private static final java.lang.String RESIZABLE_WITH_PARENT
private <any> orientation
private final <any> items
private final <any> dividers
private final <any> unmodifiableDividers
private final java.util.WeakHashMap<java.lang.Integer,java.lang.Double> dividerCache
private static final java.lang.String DEFAULT_STYLE_CLASS
private static final PseudoClass VERTICAL_PSEUDOCLASS_STATE
private static final PseudoClass HORIZONTAL_PSEUDOCLASS_STATE
public SplitPane()
public SplitPane(Node... items)
items
- The items to place inside the SplitPane.public static void setResizableWithParent(Node node, java.lang.Boolean value)
node
- A node in the SplitPane.value
- true if the node is resizable or false if not resizable.public static java.lang.Boolean isResizableWithParent(Node node)
node
- A node in the SplitPane.public final void setOrientation(Orientation value)
This property controls how the SplitPane should be displayed to the
user. javafx.geometry.Orientation#HORIZONTAL
will result in
two (or more) nodes being placed next to each other horizontally, whilst
javafx.geometry.Orientation#VERTICAL
will result in the nodes being
stacked vertically.
value
- the orientation valuepublic final Orientation getOrientation()
public final <any> orientationProperty()
public <any> getItems()
public <any> getDividers()
public void setDividerPosition(int dividerIndex, double position)
dividerIndex
- the index of the divider.position
- the divider position, between 0.0 and 1.0 (inclusive).public void setDividerPositions(double... positions)
positions
- the divider position, between 0.0 and 1.0 (inclusive).public double[] getDividerPositions()
protected Skin<?> createDefaultSkin()
-fx-skin
or set explicitly in a sub-class with setSkin(...)
.createDefaultSkin
in class Control
public static java.util.List<<any>> getClassCssMetaData()
public java.util.List<<any>> getControlCssMetaData()
getControlCssMetaData
in class Control
protected java.lang.Boolean getInitialFocusTraversable()
getInitialFocusTraversable
in class Control