package hboxtest; 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.PasswordFieldBuilder; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class HBoxTest 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(622); 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); Pane pageContent = new Pane(); pageContent.setMinSize(1000, 800); pageContent.setMaxSize(1000, 800); pageContent.setPrefSize(1000, 800); pageContent.getChildren().addAll(slot, slot2); 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 PasswordFieldBuilder.create() .promptText("Password box the first line" + "\nthe sec long line" + "\nthe third line") .focusTraversable(false).build(); } }