Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8173467

Rowspan dont work well with GridPane

XMLWordPrintable

      FULL PRODUCT VERSION :
      MacBook-Pro-de-Alexander-2:staging alexanderdealmeidapinto$ java -version
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin MacBook-Pro-de-Alexander-2.local 16.3.0 Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      When rowspan is used in a GridPane the correspondent cell dont have the expected behavior.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the code bellow to note the problem.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      First row with double the height of the rest.
      ACTUAL -
      First row with minimum width and height.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.geometry.Insets;
      import javafx.scene.Scene;
      import javafx.scene.layout.Background;
      import javafx.scene.layout.BackgroundFill;
      import javafx.scene.layout.CornerRadii;
      import javafx.scene.layout.GridPane;
      import javafx.scene.layout.Priority;
      import javafx.scene.layout.Region;
      import javafx.scene.paint.Color;
      import javafx.stage.Stage;

      public class RowSpanExample extends Application {

      public static void main(String[] args) {
      Application.launch(SampleApplication.class, args);
      }

      @Override
      public void start(Stage pStage) throws Exception {

      final GridPane root = new GridPane();

      final Region r1 = new Region();
      r1.setBackground(new Background(new BackgroundFill(Color.web("#ff0000"), CornerRadii.EMPTY, Insets.EMPTY)));
      r1.setMaxWidth(Double.MAX_VALUE);
      root.add(r1, 0, 0, 2, 2);
      r1.setMinSize(10, 10);

      final Region r2 = new Region();
      r2.setBackground(new Background(new BackgroundFill(Color.web("#00ff00"), CornerRadii.EMPTY, Insets.EMPTY)));
      root.add(r2, 0, 3, 1, 1);

      final Region r3 = new Region();
      r3.setBackground(new Background(new BackgroundFill(Color.web("#0000ff"), CornerRadii.EMPTY, Insets.EMPTY)));
      root.add(r3, 1, 3, 1, 1);

      GridPane.setHgrow(r1, Priority.ALWAYS);
      GridPane.setVgrow(r1, Priority.ALWAYS);

      GridPane.setHgrow(r2, Priority.ALWAYS);
      GridPane.setVgrow(r2, Priority.ALWAYS);

      GridPane.setHgrow(r3, Priority.ALWAYS);
      GridPane.setVgrow(r3, Priority.ALWAYS);

      final Scene scene = new Scene(root, 700, 700);

      pStage.setTitle("RowSpan Example");
      pStage.setScene(scene);
      pStage.show();

      }

      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :

      //Add constraint for each row and column.

      root.getRowConstraints().clear();
      root.getColumnConstraints().clear();

      final RowConstraints rowConstraint = new RowConstraints();
      rowConstraint.setVgrow(Priority.ALWAYS);

      final ColumnConstraints colConstraint = new ColumnConstraints();
      colConstraint.setHgrow(Priority.ALWAYS);

      for (int row = 0; row < mMaxRow; row++) {
      root.getRowConstraints().add(rowConstraint);
      }

      for (int col = 0; col < mMaxColumn; col++) {
      root.getColumnConstraints().add(colConstraint);
      }

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: