Create a GridPane with 10 rows 50 pixels tall : GridPane « JavaFX « Java






Create a GridPane with 10 rows 50 pixels tall

 

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.RowConstraints;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage stage) {
        Group root = new Group();
        Scene scene = new Scene(root, 500, 200);
        stage.setScene(scene);

        GridPane gridpane = new GridPane();
        for (int i = 0; i < 10; i++) {
            RowConstraints row = new RowConstraints(50);
            gridpane.getRowConstraints().add(row);
        }
    
        
        root.getChildren().add(gridpane);

        stage.show();
        
    }
    public static void main(String[] args) {
        launch(args);
    }
}

   
  








Related examples in the same category

1.Using GridPane to layout controls
2.Using GridPane to layout form
3.create a GridPane with 5 columns 100 pixels wide
4.GridPane where columns take 25%, 50%, 25% of its width
5.Layout a Login Dialog
6.Percent Height for GridPane Row
7.Login window