package helloworld; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.SplitPane; import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class HelloSplitPaneJc extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { stage.setTitle("SplitPane"); final SplitPane sp = new SplitPane(); sp.setPrefSize(300, 200); AnchorPane ap1 = new AnchorPane(); ap1.setPrefWidth(100); AnchorPane ap2 = new AnchorPane(); ap2.setPrefWidth(100); Button button = new Button("Test"); sp.getItems().addAll(ap1, ap2, button); final TextField tfDivider1 = new TextField(); tfDivider1.setPromptText("Change divider 1"); tfDivider1.setOnAction(new EventHandler() { public void handle(ActionEvent t) { sp.setDividerPosition(0, new Double(tfDivider1.getText())); } }); final TextField tfDivider2 = new TextField(); tfDivider2.setPromptText("Change divider 2"); tfDivider2.setOnAction(new EventHandler() { public void handle(ActionEvent t) { sp.setDividerPosition(1, new Double(tfDivider2.getText())); } }); VBox vbox = new VBox(20); vbox.setLayoutX(40); vbox.setLayoutY(25); vbox.getChildren().addAll(sp, tfDivider1, tfDivider2); Scene scene = new Scene(new Group(vbox), 620, 400); stage.setScene(scene); stage.show(); } }