Wrapping Label text in a VBox using FXML
<p>I'm writing a JavaFX application and I'd like to create a screen that contains 2 long pieces of text. I don't know what the text is ahead of time, it will be filled in by some code at run time.</p>

<p>To do this I thought I'd make a VBox with 2 Labels. I assume that if I don't add dimensions, the Labels will span the VBox. Since the text is long I'd like it to wrap.</p>

<p>Here's the FXML that I tried:</p>

<pre><code>&lt;VBox spacing="20" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"&gt;
   &lt;children&gt;
      &lt;Label fx:id="label1" text="Dummy Text" wrapText="true" /&gt;   
      &lt;Label fx:id="label2" text="Dummy Text" wrapText="true" /&gt;  
   &lt;/children&gt;
&lt;/VBox&gt;
</code></pre>

<p>This doesn't work because the text doesn't wrap but simply goes off the right side of the window. What do I need to get this to work? </p>