title: JavaFX: ComboBox in GridPane causes unnecessary resizing
body: <p>I have a <code>GridPane</code> with 5 columns. These are my <code>hgrow</code> setting for the column constraints respectively.</p>
  <ol>
  <li><code>SOMETIMES</code></li>
  <li><code>ALWAYS</code></li>
  <li><code>SOMETIMES</code> (fixed sized)</li>
  <li><code>SOMETIMES</code></li>
  <li><code>ALWAYS</code></li>
  </ol>
  <p>The whole <code>GridPane</code> is basically a layout for a two-column form. My columns 1 and 4 (index 0 and 3) are field labels, while columns 2 and 5 are the input fields (<code>TextField</code> etc). Column 3 is just a fixed-width padding between the two form columns.</p>
  <p>I have some <code>ComboBox</code> in my form - some are on the left column, some on the right column. I have set the max width of all the <code>ComboBox</code> to <code>MAX_VALUE</code>.</p>
  <p>When the form loads, the layout looks like what I had intended (both input-field columns have equal width). However, when I click on any of the <code>ComboBox</code>, it would cause the column that the clicked <code>ComboBox</code> is on to increase in width - which causes the other input-field column to decrease by the same amount.</p>
  <p>I can alternate clicking on the <code>ComboBox</code> on the left and right, and the widths of both columns would keep changing. The change would get smaller and smaller and eventually the columns would stop resizing. The end result is that the two columns are not equal in width.</p>
  <p>I have the same problem for another control <code>JFXDatePicker</code> from <code>JFoenix</code> library.</p>
  <p>Another constraint I have is that this form is within a <code>SplitPane</code>, so I have to avoid setting explicit widths.</p>
  <p>What can I do to fix this problem?</p>
  <h2>Edit</h2>
  <p>I guess I will attach a sample here considering how little view this question has.</p>
  <pre><code>@Override
  public void start(Stage primaryStage) throws Exception {
      VBox root = FXMLLoader.load(getClass().getResource(&quot;Test.fxml&quot;));
      Scene sc = new Scene(root);
      primaryStage.setScene(sc);
      primaryStage.show();
  }
  </code></pre>
  <p>FXML:</p>
  <pre><code>&lt;VBox maxHeight=&quot;1.7976931348623157E308&quot; maxWidth=&quot;1.7976931348623157E308&quot; minHeight=&quot;-Infinity&quot; minWidth=&quot;-Infinity&quot; xmlns=&quot;http://javafx.com/javafx/8.0.111&quot; xmlns:fx=&quot;http://javafx.com/fxml/1&quot;&gt;
      &lt;padding&gt;
          &lt;Insets bottom=&quot;30.0&quot; left=&quot;30.0&quot; right=&quot;30.0&quot; top=&quot;30.0&quot; /&gt;
      &lt;/padding&gt;
     &lt;children&gt;
        &lt;GridPane hgap=&quot;6.0&quot; vgap=&quot;6.0&quot; VBox.vgrow=&quot;ALWAYS&quot;&gt;
          &lt;columnConstraints&gt;
            &lt;ColumnConstraints hgrow=&quot;SOMETIMES&quot; /&gt;
            &lt;ColumnConstraints hgrow=&quot;ALWAYS&quot; maxWidth=&quot;1.7976931348623157E308&quot; /&gt;
              &lt;ColumnConstraints hgrow=&quot;SOMETIMES&quot; /&gt;
              &lt;ColumnConstraints hgrow=&quot;ALWAYS&quot; maxWidth=&quot;1.7976931348623157E308&quot; /&gt;
          &lt;/columnConstraints&gt;
          &lt;rowConstraints&gt;
            &lt;RowConstraints minHeight=&quot;10.0&quot; vgrow=&quot;SOMETIMES&quot; /&gt;
            &lt;RowConstraints minHeight=&quot;10.0&quot; vgrow=&quot;SOMETIMES&quot; /&gt;
            &lt;RowConstraints minHeight=&quot;10.0&quot; vgrow=&quot;SOMETIMES&quot; /&gt;
          &lt;/rowConstraints&gt;
           &lt;children&gt;
              &lt;Label text=&quot;Left 1&quot; GridPane.halignment=&quot;RIGHT&quot; /&gt;
              &lt;Label text=&quot;Left 2&quot; GridPane.halignment=&quot;RIGHT&quot; GridPane.rowIndex=&quot;1&quot; /&gt;
              &lt;Label text=&quot;Left 3&quot; GridPane.halignment=&quot;RIGHT&quot; GridPane.rowIndex=&quot;2&quot; /&gt;
              &lt;Label text=&quot;Right 1&quot; GridPane.columnIndex=&quot;2&quot; GridPane.halignment=&quot;RIGHT&quot; /&gt;
              &lt;Label text=&quot;Right 2&quot; GridPane.columnIndex=&quot;2&quot; GridPane.halignment=&quot;RIGHT&quot; GridPane.rowIndex=&quot;1&quot; /&gt;
              &lt;Label text=&quot;Right 3&quot; GridPane.columnIndex=&quot;2&quot; GridPane.halignment=&quot;RIGHT&quot; GridPane.rowIndex=&quot;2&quot; /&gt;
              &lt;ComboBox maxWidth=&quot;1.7976931348623157E308&quot; GridPane.columnIndex=&quot;1&quot; /&gt;
              &lt;ComboBox maxWidth=&quot;1.7976931348623157E308&quot; GridPane.columnIndex=&quot;3&quot; /&gt;
              &lt;ComboBox maxWidth=&quot;1.7976931348623157E308&quot; GridPane.columnIndex=&quot;3&quot; GridPane.rowIndex=&quot;2&quot; /&gt;
           &lt;/children&gt;
        &lt;/GridPane&gt;
     &lt;/children&gt;
  &lt;/VBox&gt;
  </code></pre>
  <p>The result:</p>
  <p><a href="https://i.stack.imgur.com/duN75.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/duN75.gif" alt="Result" /></a></p>
  <p>As shown in the GIF, the layout is what I wanted when the window is initially launched. When I clicked on one of the combobox at the right side, the column suddenly increased its width and shrunk the other column. I need the width of both columns to remain constant when any of the comboboxes are clicked.</p>
  <h2>Update</h2>
  <p>It seems like I had missed out some information in my question. The final result I need is a <code>GridPane</code> with 4 columns in two label-input pairs. An extra column can be added between the pairs to add additional padding between the pairs, but it's optional. The whole grid will be in a resizable environment (for example in my example - a resizable Stage). I believe resizable environment is not unreasonable, otherwise I would have given all columns absolute sizes (or even use any <code>Pane</code> and gave it absolute position) and the problem wouldn't have existed.</p>
  <p>Both the labels must always be visible (unless the whole <code>GridPane</code> is reduced to a terribly small size), and any additional space must be given to the input controls (<code>TextField</code>, <code>ComboBox</code> etc). Similarly, if the <code>GridPane</code> is shrunk, I expect the input columns to shrink instead of the label columns. The label columns should maintain a fixed size throughout, and this size is the minimum size that is needed to display all labels without ellipsis appearing.</p>
  <p>As the final form has a mixture of different input controls, it would make the <code>ComboBox</code> look weird if it is not resized to the same width as other input controls in the same column. I admit that this requirement is me being picky.</p>
  <p>I also expect both the input columns to have the same width, and that this must remain true at all times.</p>
  <h2>Another Update</h2>
  <p>I have made a <a href="https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8210037" rel="nofollow noreferrer">bug report</a> on this, and it is currently still open with a P3 priority.</p>