/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package test; import javafx.application.Application; import javafx.geometry.HPos; import javafx.geometry.VPos; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.LabelBuilder; import javafx.scene.control.TextField; import javafx.scene.control.TextFieldBuilder; import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPaneBuilder; import javafx.scene.layout.Priority; import javafx.stage.Stage; /** * * @author fabriceb */ public class Main extends Application { /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { GridPane root = GridPaneBuilder.create().id("root").build(); // Works ok. root.setGridLinesVisible(true); root.setHgap(6); root.setVgap(6); /* // -fx-vgap is ignored root.setStyle("-fx-grid-lines-visible:true; -fx-hgap: 6; -fx-vgap: 6;"); */ for (int row = 0; row < 20; row++) { Label label = LabelBuilder.create().id("label" + row).text("Label_" + row).build(); GridPane.setConstraints(label, 0, row); TextField textField = TextFieldBuilder.create().id("textField" + row).promptText("TextField_" + row).build(); GridPane.setConstraints(textField, 1, row, 1, 1, HPos.CENTER, VPos.BASELINE, Priority.ALWAYS, Priority.NEVER); root.getChildren().addAll(label, textField); } primaryStage.setTitle("Hello World!"); primaryStage.setScene(new Scene(root)); primaryStage.show(); } }