Search code examples
javafxsplitpane

JavaFx: Unresizeable divider in SplitPane


I'm wondering if there is any option to set divider postition to constant position (SplitPane) in FXML file? I'm trying to hold this divider in determined place.


Solution

  • Yes it possible with one trick. You have to set Pref Width for your SplitPane like here: enter image description here

    Then you have to set Min Width for each AnchorPane like here: enter image description here

    And it will be not possible to move divider, because divider has some rules:

    The dividers in a SplitPane have the following behavior

    • Dividers cannot overlap another divider
    • Dividers cannot overlap a node.
    • Dividers moving to the left/top will stop when the node's min size is reached.
    • Dividers moving to the right/bottom will stop when the node's max size is reached.

    Source: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/SplitPane.html