Percent Height for GridPane Row : GridPane « JavaFX « Java






Percent Height for GridPane Row

 

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();
        RowConstraints row1 = new RowConstraints();
        row1.setPercentHeight(25);
        RowConstraints row2 = new RowConstraints();
        row2.setPercentHeight(50);
        RowConstraints row3 = new RowConstraints();
        row3.setPercentHeight(25);
        gridpane.getRowConstraints().addAll(row1,row2,row3);
        
        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.Create a GridPane with 10 rows 50 pixels tall
7.Login window