package test; import com.sun.javafx.runtime.VersionInfo; import javafx.application.Application; import javafx.geometry.Pos; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.MenuItem; import javafx.scene.control.SplitMenuButtonBuilder; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class Test extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { stage.setScene(getScene()); stage.setTitle(VersionInfo.getRuntimeVersion()); stage.show(); } private Scene getScene() { HBox hbox = new HBox(); hbox.setAlignment(Pos.BASELINE_CENTER); hbox.getChildren().add(createControl()); hbox.getChildren().add(createControl()); hbox.setPrefSize(270, 270); hbox.setStyle("-fx-border-color: darkgray;"); hbox.setFillHeight(false); VBox slot = new VBox(); slot.getChildren().add(new Label("Alignment:" + Pos.BASELINE_CENTER)); slot.getChildren().addAll(hbox); slot.setTranslateX(0); HBox hbox2 = new HBox(); hbox2.setAlignment(Pos.TOP_LEFT); hbox2.getChildren().add(createControl()); hbox2.getChildren().add(createControl()); hbox2.setPrefSize(270, 270); hbox2.setStyle("-fx-border-color: darkgray;"); hbox2.setFillHeight(false); VBox slot2 = new VBox(); slot2.getChildren().add(new Label("Alignment:" + Pos.TOP_LEFT)); slot2.getChildren().addAll(hbox2); slot2.setTranslateX(311); GridPane pane = new GridPane(); for (int k = 0; k < 2; ++k) { Node n = createControl(); GridPane.setConstraints(n, k, k); pane.getChildren().add(n); } pane.setPrefSize(250, 250); pane.setGridLinesVisible(true); pane.setStyle("-fx-border-color: darkgray;"); VBox slot3 = new VBox(); slot3.getChildren().add(new Label("Grid pane")); slot3.getChildren().addAll(pane); slot3.setTranslateX(622); Pane pageContent = new Pane(); pageContent.setMinSize(1000, 800); pageContent.setMaxSize(1000, 800); pageContent.setPrefSize(1000, 800); pageContent.getChildren().addAll(slot, slot2, slot3); VBox vBox = new VBox(); vBox.getChildren().add(pageContent); pageContent.setTranslateX(20); pageContent.setTranslateY(20); Group root = new Group(); root.getChildren().add(vBox); return new Scene(root, 1050, 940); } private Node createControl() { return SplitMenuButtonBuilder.create() .text("Split box the first line" + "\nthe sec long line" + "\nthe third line") .items(new MenuItem("Split box the first line" + "\nthe sec long line" + "\nthe third line",new Rectangle(10, 10, Color.BLUE))) .graphic(new Rectangle(10, 10, Color.RED)) .build(); } }