How can I achieve proportional resize of whole SplitPane?
public class JfxSplitPaneTest extends Application {
@Override
public void start(Stage stage
Try to add Change Listener to stage.widthProperty() and stage.heightProperty(). And call this:
split.setDividerPositions(0.1f, 0.6f, 0.9f)
The rule of thumb is to use setDividerPositions
with Platform.runLater
when the resize event is triggered.
You probably want to start with a default ratio, let the user change that ratio, and maintain this ratio whatever it is when there's a resize event. Let's consider a 25/75 vertical FX splitPane
in some stage
:
splitPane.setDividerPositions(0.25f, 0.75f);
stage.heightProperty().addListener((obs, oldVal, newVal) -> {
double[] positions = splitPane.getDividerPositions(); // reccord the current ratio
Platform.runLater(() -> splitPane.setDividerPositions(positions)); // apply the now former ratio
});
Try to set the divisors like AS3Boyan said
split.setDividerPositions(0.1f, 0.6f, 0.9f)
and add this:
How can I avoid a SplitPane to resize one of the panes when the window resizes?