title: JavaFX: Making an Object with a Shape and Text
body: <p>I am trying to make an object that can be added to my pane.
  This object would contain a Shape and some text.</p>
  
  <p>through invoking:</p>
  
  <pre><code>pane#getChildren()#add(new TextEllipse(...))
  </code></pre>
  
  <p>it would add an Ellipse with text in the center to the referenced pane.</p>
  
  <p>My class for such an object is represented below:</p>
  
  <pre><code>    public class TextEllipse extends ShapeEllipse {
  
          public TextEllipse(final String text, final double x, final double y) {
              super(text, x, y);
          }
   @Override
      protected Shape createShape() {
          final double PADDING = 10;
          final Ellipse ellipse = new Ellipse();
          ellipse.setRadiusX(getText().getLayoutBounds().getWidth() / 2 + PADDING);
          ellipse.setRadiusY(10);
          ellipse.setStroke(Color.BLACK);
          ellipse.setFill(Color.WHITE);
          return ellipse;
      }
      }
  
  
  public abstract class TextShape extends Pane {
      private final Text text;
      private final Shape shape;
  
      public TextShape(final String text, final double x, final double y) {
          this.text = new Text(x, y, text);
          shape = createShape();
      }
  
      protected abstract Shape createShape();
  
      public Text getText() {
          return text;
      }
  
      public Shape getBackgroundShape() {
          return shape;
      }
  }
  </code></pre>
  
  <p>I've followed d.j. brown's method - however, when I invoke </p>
  
  <pre><code>pane#getChildren()#add(new TextEllipse(...))
  </code></pre>
  
  <p>Nothing shows up on the canvas.</p>
  
  <p>However, when I do:</p>
  
  <pre><code>pane#getChildren()#add(new TextEllipse(...)#getBackgroundShape())
  </code></pre>
  
  <p>The ellipse does show up.</p>
  
  <p>Why won't the ellipse and text show up if I just add the TextEllipse object?</p>