I don't know why the cell content can exceed the limits of the gridpanes rowconstraint, although a maximum is set. I tried to clip it somehow, but I don't get the actual height of the cell (when I would change it dynamically). As you can see on the image, the green rectangle is too big. How could I restrict its height dynamically?
Here's a small example:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.RowConstraints;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
GridPane gp = new GridPane();
gp.setGridLinesVisible(true);
gp.setVgap(10);
gp.add(new Pane(new Rectangle(100,100,Color.rgb(255, 0, 0, 0.5))), 0, 0);
gp.add(new Pane(new Rectangle(100,200,Color.rgb(0,255,0,0.5))), 0, 1);
gp.getRowConstraints().add(new RowConstraints(50,100,110));
gp.getRowConstraints().add(new RowConstraints(50,100,110));
Scene scene = new Scene(gp,400,400);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}