title: JavaFX 8 - GridPane autosizing issue
body: <p>There is an issue with the GridPane autosizing when setting some specific span configuration.</p>
  
  <p>The following configuration works as I expect:</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.geometry.Insets;
  import javafx.scene.Scene;
  import javafx.scene.control.Label;
  import javafx.scene.layout.Border;
  import javafx.scene.layout.BorderStroke;
  import javafx.scene.layout.BorderStrokeStyle;
  import javafx.scene.layout.BorderWidths;
  import javafx.scene.layout.CornerRadii;
  import javafx.scene.layout.GridPane;
  import javafx.scene.paint.Color;
  import javafx.stage.Stage;
  
  public class GridPaneWidthIssue extends Application {
  
      public static void main(String... arguments) {
          launch(arguments);
      }
  
      @Override
      public void start(Stage primaryStage) throws Exception {
  
          GridPane gridPane = new GridPane();
  
          BorderStroke borderStroke = new BorderStroke(Color.RED,
                  BorderStrokeStyle.SOLID, CornerRadii.EMPTY,
                  BorderWidths.DEFAULT);
  
          Border border = new Border(borderStroke);
          gridPane.setBorder(border);
          gridPane.setGridLinesVisible(true);
          gridPane.setHgap(2);
          gridPane.setVgap(2);
          gridPane.setPadding(new Insets(10));
  
          Label column0 = new Label("Column 0");
          Label column1 = new Label("Column 1");
          Label column2 = new Label("Column 2");
          Label column01 = new Label("Span column 0 and 1");
          Label column012 = new Label("Span column 0, 1 and 2");
  
          gridPane.add(column0, 0, 0);
          gridPane.add(column1, 1, 0);
          gridPane.add(column2, 2, 0);
          gridPane.add(column01, 0, 1, 2, 1);
          gridPane.add(column012, 0, 2, 3, 1);
  
          Scene scene = new Scene(gridPane);
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  }
  </code></pre>
  
  <p>I cannot post image yet to prove it, but I can verify the following assertion:</p>
  
  <p>**gridpane.width = column0.width + column1.width + column2.width</p>
  
  <p>When I remove the labels in the row 0, I get the following code:</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.geometry.Insets;
  import javafx.scene.Scene;
  import javafx.scene.control.Label;
  import javafx.scene.layout.Border;
  import javafx.scene.layout.BorderStroke;
  import javafx.scene.layout.BorderStrokeStyle;
  import javafx.scene.layout.BorderWidths;
  import javafx.scene.layout.CornerRadii;
  import javafx.scene.layout.GridPane;
  import javafx.scene.paint.Color;
  import javafx.stage.Stage;
  
  public class GridPaneWidthIssue extends Application {
  
      public static void main(String... arguments) {
          launch(arguments);
      }
  
      @Override
      public void start(Stage primaryStage) throws Exception {
  
          GridPane gridPane = new GridPane();
  
          BorderStroke borderStroke = new BorderStroke(Color.RED,
                  BorderStrokeStyle.SOLID, CornerRadii.EMPTY,
                  BorderWidths.DEFAULT);
  
          Border border = new Border(borderStroke);
          gridPane.setBorder(border);
          gridPane.setGridLinesVisible(true);
          gridPane.setHgap(2);
          gridPane.setVgap(2);
          gridPane.setPadding(new Insets(10));
  
          Label column0 = new Label("Column 0");
          Label column1 = new Label("Column 1");
          Label column2 = new Label("Column 2");
          Label column01 = new Label("Span column 0 and 1");
          Label column012 = new Label("Span column 0, 1 and 2");
  
          // gridPane.add(column0, 0, 0);
          // gridPane.add(column1, 1, 0);
          // gridPane.add(column2, 2, 0);
          gridPane.add(column01, 0, 1, 2, 1);
          gridPane.add(column012, 0, 2, 3, 1);
  
          Scene scene = new Scene(gridPane);
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  }
  </code></pre>
  
  <p>And the result is not correct:</p>
  
  <p><strong>gridpane.width > column0.width + column1.width + column2.width</strong></p>
  
  <p>I did not verify it, but I guess it is :</p>
  
  <p><strong>gridpane.width = column0.width + column1.width + column0.width + column1.width + column2.width</strong></p>
  
  <p>JavaFX issue or I misunderstood the Gridpane sizing policy ?</p>
  
  <p>Case 1: OK</p>
  
  <p><img src="https://i.stack.imgur.com/l485e.png" alt="enter image description here"></p>
  
  <p>Case 2: KO (empty space in the GridPane)</p>
  
  <p><img src="https://i.stack.imgur.com/KxNCf.png" alt="enter image description here"></p>