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

GridPane, ColumnConstraint, percentWidth not working smoothly

XMLWordPrintable

      Since using JDK 8u40, if a GridPane has some columns (fixed number) and these column are defined to use a percent of the width available (using percentWidth of columnConstraint), the refresh of the various column size will not occur in the smooth way they use to using JDK 8u31. This leads to ugly spaces where a component would have fitted perfectly before.

      Same behavior observed on 8u60 EA.

      Here is a sample code I used to simply show the issue :

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.ColumnConstraints;
      import javafx.scene.layout.GridPane;
      import javafx.stage.Stage;

      public class test extends Application
      {
          @Override
          public void start(final Stage stage) throws Exception
          {
           // Création de la fenêtre
              Scene scene = new Scene(construire());
              stage.setScene(scene);
              stage.setWidth(400);
              stage.setHeight(400);
              stage.show();
          }
          
          
          private GridPane construire()
          {
           GridPane pane = new GridPane();
           pane.setGridLinesVisible(true);
          
           // create a 20 column gridPane
           ColumnConstraints col = new ColumnConstraints();
           // the column share the whole gridPane space
           col.setPercentWidth(100/20);
           for( int i = 0; i < 20; i++)
           {
           pane.getColumnConstraints().add(col);
           }
          
           // add some label (one would be enough to force the gridPane to have a non 0 height)
           Label lbl1 = new Label();
           lbl1.setMaxWidth(Double.MAX_VALUE);
           lbl1.setStyle("-fx-background-color:red");
           pane.add(lbl1, 0, 0, 4, 1);
          
           Label lbl2 = new Label();
           lbl2.setMaxWidth(Double.MAX_VALUE);
           lbl2.setStyle("-fx-background-color:blue");
           pane.add(lbl2, 4, 0, 4, 1);
          
           Label lbl3 = new Label();
           lbl3.setMaxWidth(Double.MAX_VALUE);
           lbl3.setStyle("-fx-background-color:yellow");
           pane.add(lbl3, 8, 0, 4, 1);
          
           Label lbl4 = new Label();
           lbl4.setMaxWidth(Double.MAX_VALUE);
           lbl4.setStyle("-fx-background-color:black");
           pane.add(lbl4, 12, 0, 4, 1);
          
           Label lbl5 = new Label();
           lbl5.setMaxWidth(Double.MAX_VALUE);
           lbl5.setStyle("-fx-background-color:green");
           pane.add(lbl5, 16, 0, 4, 1);

           return(pane);
          }

      }

            ckyang Chien Yang (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: