title: How to implement a custom JavaFX control based on a Pane
body: <p>I am looking to implement a base, extendable custom control in JavaFX 8, comprising a pane with other controls added to it.</p>
  
  <p>So, for example, it may comprise of a <code>GridPane</code> holding a <code>TextField</code>, a <code>Button</code> and a <code>CheckBox</code>.</p>
  
  <p>I do not want to subclass <code>Pane</code> or <code>GridPane</code> because I do not want to expose those APIs to the user. So, "a node which is made up of a grid pane" as opposed to "a node which extends a grid pane".</p>
  
  <p>I see that extending <code>Region</code> or <code>Control</code> is possible, which is recommended? What is required to delegate sizing and layout to the pane?</p>
  
  <pre><code>public class BasePaneControl extends Control {
      private final Pane pane;
  
      public BasePaneControl(Pane pane) {
          this.pane = pane;
          getChildren().add(pane);
      }
  
      // What do I need to delegate here to the pane to get sizing
      // to affect and be calculated by the pane?
  }
  
  public class MyControl extends BasePaneControl {
      private final GridPane gp = new GridPane();
      public MyControl() {
          super(gp);
          gp.add(new TextField(), 0, 0);
          gp.add(new CheckBox(), 0, 1);
          gp.add(new Button("Whatever"), 0, 2);
      }
  
      // some methods to manage how the control works.
  }
  </code></pre>
  
  <p>I need help implementing <code>BasePaneControl</code> above please.</p>