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 and setDividerPositions 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.getChildren().add(new Button("Button One"));
final StackPane sp2 = new StackPane();
sp2.getChildren().add(new Button("Button Two"));
final StackPane sp3 = new StackPane();
sp3.getChildren().add(new Button("Button Three"));
sp.getItems().addAll(sp1, sp2, sp3);
sp.setDividerPositions(0.3f, 0.6f, 0.9f);
| Modifier and Type | Class and Description |
|---|---|
| public static class | SplitPane.
Represents a single divider in the SplitPane. |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private final Map | |
| private final ObservableList | |
| private static final PseudoClass | |
| private final ObservableList | |
| private ObjectProperty | |
| private static final String | |
| private final ObservableList | |
| private static final PseudoClass |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public static List | Returns: theCssMetaDataHides javafx. Gets the |
| public List | getControlCssMetaData()
Overrides javafx. Gets the unmodifiable list of the control's CSS-styleable properties. |
| public double[] | Returns: an array of double containing the position of each divider.Returns an array of double containing the position of each divider. |
| public ObservableList | Returns: the list of dividers.Returns an unmodifiable list of all the dividers in this SplitPane. |
| protected Boolean | getInitialFocusTraversable()
Overrides javafx. Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value. |
| public ObservableList | Returns: the list of items in this SplitPane.Returns an ObservableList which can be use to modify the contents of the SplitPane. |
| public final Orientation | |
| public static Boolean | Returns: true if the node is resizable false otherwise.A node in the SplitPane. node)Return true if the node is resizable when the parent container is resized false otherwise. |
| public final ObjectProperty | Returns: the orientation property for the SplitPaneThe orientation for the SplitPane. |
| public void | setDividerPosition(int
the index of the divider. dividerIndex, double the divider position, between 0.0 and 1.0 (inclusive). position)Sets the position of the divider at the specified divider index. |
| public void | setDividerPositions(double...
the divider position, between 0.0 and 1.0 (inclusive). positions)Sets the position of the divider |
| public final void | setOrientation(Orientation
the orientation value value)This property controls how the SplitPane should be displayed to the user. |
| public static void | setResizableWithParent(Node
A node in the SplitPane. node, Boolean true if the node is resizable or false if not resizable. value)Sets a node in the SplitPane to be resizable or not when the SplitPane is resized. |
| DEFAULT_STYLE_CLASS | back to summary |
|---|---|
| private static final String DEFAULT_STYLE_CLASS | |
| dividerCache | back to summary |
|---|---|
| private final Map<Integer, Double> dividerCache | |
| dividers | back to summary |
|---|---|
| private final ObservableList<SplitPane. | |
| HORIZONTAL_PSEUDOCLASS_STATE | back to summary |
|---|---|
| private static final PseudoClass HORIZONTAL_PSEUDOCLASS_STATE | |
| items | back to summary |
|---|---|
| private final ObservableList<Node> items | |
| orientation | back to summary |
|---|---|
| private ObjectProperty<Orientation> orientation | |
| RESIZABLE_WITH_PARENT | back to summary |
|---|---|
| private static final String RESIZABLE_WITH_PARENT | |
| unmodifiableDividers | back to summary |
|---|---|
| private final ObservableList<SplitPane. | |
| VERTICAL_PSEUDOCLASS_STATE | back to summary |
|---|---|
| private static final PseudoClass VERTICAL_PSEUDOCLASS_STATE | |
| SplitPane | back to summary |
|---|---|
| public SplitPane() Creates a new SplitPane with no content. | |
| SplitPane | back to summary |
|---|---|
| public SplitPane(Node... items) Creates a new SplitPane with the given items set as the content to split between one or more dividers.
| |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. Create a new instance of the default skin for this control. This is called to create a skin for the control if
no skin is provided via CSS
| |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Gets the
| |
| getControlCssMetaData | back to summary |
|---|---|
| public List Overrides javafx. Doc from javafx. Gets the unmodifiable list of the control's CSS-styleable properties.
| |
| getDividerPositions | back to summary |
|---|---|
| public double[] getDividerPositions() Returns an array of double containing the position of each divider.
| |
| getDividers | back to summary |
|---|---|
| public ObservableList Returns an unmodifiable list of all the dividers in this SplitPane.
| |
| getInitialFocusTraversable | back to summary |
|---|---|
| protected Boolean getInitialFocusTraversable() Overrides javafx. Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value. This method is overridden as by default UI controls have focus traversable set to true, but that is not appropriate for this control.
| |
| getItems | back to summary |
|---|---|
| public ObservableList Returns an ObservableList which can be use to modify the contents of the SplitPane. The order the nodes are placed into this list will be the same order in the SplitPane.
| |
| getOrientation | back to summary |
|---|---|
| public final Orientation getOrientation() The orientation for the SplitPane.
| |
| isResizableWithParent | back to summary |
|---|---|
| public static Boolean isResizableWithParent(Node node) Return true if the node is resizable when the parent container is resized false otherwise. | |
| orientationProperty | back to summary |
|---|---|
| public final ObjectProperty The orientation for the SplitPane.
| |
| setDividerPosition | back to summary |
|---|---|
| public void setDividerPosition(int dividerIndex, double position) Sets the position of the divider at the specified divider index.
| |
| setDividerPositions | back to summary |
|---|---|
| public void setDividerPositions(double... positions) Sets the position of the divider
| |
| setOrientation | back to summary |
|---|---|
| public final void setOrientation(Orientation value) This property controls how the SplitPane should be displayed to the
user.
| |
| setResizableWithParent | back to summary |
|---|---|
| public static void setResizableWithParent(Node node, Boolean value) Sets a node in the SplitPane to be resizable or not when the SplitPane is resized. By default all node are resizable. Setting value to false will prevent the node from being resized. | |
| Modifier and Type | Field and Description |
|---|---|
| private DoubleProperty | position
Represents the location where the divider should ideally be positioned, between 0.0 and 1.0 (inclusive). |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final double | |
| public final DoubleProperty | |
| public final void |
| position | back to summary |
|---|---|
| private DoubleProperty position Represents the location where the divider should ideally be positioned, between 0.0 and 1.0 (inclusive). 0.0 represents the left- or top-most point, and 1.0 represents the right- or bottom-most point (depending on the horizontal property). The SplitPane will attempt to get the divider to the point requested, but it must take into account the minimum width/height of the nodes contained within it. As the user drags the SplitPane divider around this property will be updated to always represent its current location.
| |
| Divider | back to summary |
|---|---|
| public Divider() Creates a default Divider instance. | |
| getPosition | back to summary |
|---|---|
| public final double getPosition() | |
| positionProperty | back to summary |
|---|---|
| public final DoubleProperty positionProperty() | |
| setPosition | back to summary |
|---|---|
| public final void setPosition(double value) | |
| Modifier and Type | Field and Description |
|---|---|
| private static final CssMetaData | |
| private static final List |
| Access | Constructor and Description |
|---|---|
| private |
| ORIENTATION | back to summary |
|---|---|
| private static final CssMetaData<SplitPane, Orientation> ORIENTATION | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| StyleableProperties | back to summary |
|---|---|
| private StyleableProperties() | |