title: Why won't javafx rectangles display their color when sizing to the parent container's getWidth/Height?
body: <p>I'm trying to use rectangles as the background for text labels by putting them behind the VBox text in a StackPane, but when I try using the VBox's getWidth() or getHeight() values for the rectangle's size, the rectangle does not appear. I suppose I could </p>
  
  <p>This works, displaying the blue rectangle behind the text, though not the size I want:</p>
  
  <pre><code>StackPane tadPane = new StackPane();
  tadPane.setBorder(border);
  Rectangle tadRec = new Rectangle();
  VBox tadBox = new VBox();
  Label totalXP = new Label("Total XP: ");
  Label diff = new Label("Difficulty: ");
  tadBox.getChildren().addAll(totalXP,diff);
  tadRec.setWidth(50);
  tadRec.setHeight(50);
  tadRec.setFill(Color.BLUE);
  tadPane.getChildren().addAll(tadRec,tadBox);
  </code></pre>
  
  <p>But this doesn't, the rectangle is not visible:</p>
  
  <pre><code>StackPane tadPane = new StackPane();
  tadPane.setBorder(border);
  Rectangle tadRec = new Rectangle();
  VBox tadBox = new VBox();
  Label totalXP = new Label("Total XP: ");
  Label diff = new Label("Difficulty: ");
  tadBox.getChildren().addAll(totalXP,diff);
  tadRec.setWidth(tadBox.getWidth());
  tadRec.setHeight(tadBox.getHeight());
  tadRec.setFill(Color.BLUE);
  tadPane.getChildren().addAll(tadRec,tadBox);
  </code></pre>
  
  <p>I can't understand why this would be happening. Raw numbers in the setWidth/Height work, but the getWidth/Height from the VBox should be returning numbers too if the labels with text are inside.</p>