title: JavaFX: Button's width in custom gridpane
body: <p>I would like to have buttons with equal(maximum) width in a gridpane. </p>
  
  <p>When I'm trying to set it directly in FXML - it works perfectly.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
              fx:controller="TestController"&gt;
      &lt;children&gt;
          &lt;GridPane AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.bottomAnchor="0"
                    AnchorPane.topAnchor="0"&gt;
              &lt;columnConstraints&gt;
                  &lt;ColumnConstraints hgrow="SOMETIMES" percentWidth="50.0"/&gt;
                  &lt;ColumnConstraints hgrow="SOMETIMES" percentWidth="50.0"/&gt;
              &lt;/columnConstraints&gt;
              &lt;children&gt;
                  &lt;Button maxWidth="Infinity" text="Button1" GridPane.columnIndex="0"/&gt;
                  &lt;Button maxWidth="Infinity" text="Button2" GridPane.columnIndex="1"/&gt;
              &lt;/children&gt;
  
          &lt;/GridPane&gt;
      &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>But when I wanted to separate the whole grid into a custom control, the buttons stopped to fill the available width.</p>
  
  <p>Here's a FXML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import CustomGridPane?&gt;
  &lt;AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
              fx:controller="TestController"&gt;
      &lt;children&gt;
          &lt;CustomGridPane AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.bottomAnchor="0" AnchorPane.topAnchor="0"&gt;
          &lt;/CustomGridPane&gt;
      &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>And an extension:</p>
  
  <pre><code>public class CustomGridPane extends GridPane {
  
      private Button button1 = new Button("button1");
      private Button button2 = new Button("button2");
  
      public CustomGridPane() {
          super();
          button1.maxWidth(Double.MAX_VALUE);
          button2.maxWidth(Double.MAX_VALUE);
  
          getColumnConstraints().add(new ColumnConstraints());
          getColumnConstraints().add(new ColumnConstraints());
          getColumnConstraints().get(0).setPercentWidth(50);
          getColumnConstraints().get(0).setHgrow(Priority.SOMETIMES);
          getColumnConstraints().get(1).setPercentWidth(50);
          getColumnConstraints().get(1).setHgrow(Priority.SOMETIMES);
  
          add(button1, 0, 0);
          add(button2, 1, 0);
      }
  }
  </code></pre>
  
  <p>Am I missing something?</p>