title: How to make JavaFX text wrap work?
body: <p>I can't for the life of me make JavaFX wrap text. Instead my boxes get the size of the <code>Text</code>.</p>
  
  <p>This is my main:</p>
  
  <pre><code>BorderPane main = FXMLLoader.load(getClass().getResource("main.fxml"));
  
  primaryStage.setTitle("D394");
  primaryStage.setScene(new Scene(main, 1000, 500));
  primaryStage.getScene().getStylesheets().add("main.css");
  primaryStage.show();
  </code></pre>
  
  <p>And this is my main.fxml. It's pretty big, sorry for that.</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;BorderPane prefHeight="401.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/8.0.112-ea"
              xmlns:fx="http://javafx.com/fxml/1" fx:controller="ro.softvisionmedia.gui.MainController"&gt;
      &lt;top&gt;
          &lt;MenuBar fx:id="menuBar" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"&gt;
              &lt;Menu items="" text="Lala"&gt;
              &lt;/Menu&gt;
          &lt;/MenuBar&gt;
      &lt;/top&gt;
  
      &lt;center&gt;
          &lt;TabPane fx:id="tabPane"&gt;
  
              &lt;Tab id="tab_1" fx:id="tab1_D394" closable="false" text="D394"&gt;
              &lt;/Tab&gt;
  
              &lt;Tab fx:id="tab2_DateIdentif" closable="false" text="Date identificare"&gt;
                  &lt;TabPane fx:id="tabPane_dateIdentif"&gt;
                      &lt;Tab fx:id="identifPersTVA" closable="false" text="Persoana inregistrata in scopuri de TVA"&gt;
                      &lt;/Tab&gt;
  
                      &lt;Tab fx:id="identifRepFiscal" closable="false" text="Reprezentant fiscal/legal/imputernicit"&gt;
                      &lt;/Tab&gt;
                      &lt;Tab fx:id="identifIntocmit" closable="false" text="Intocmitor"&gt;
                          &lt;VBox fx:id="vBoxIntocmitor"&gt;
                              &lt;HBox&gt;
                                  &lt;TextFlow&gt;
                                      &lt;Text text="Subsemnatul "/&gt;
                                      &lt;Text fx:id="denumireRtext"/&gt;
                                      &lt;Text text=", in calitate de reprezentant legal, "/&gt;
                                      &lt;TextField fx:id="functieReprez"/&gt;
                                      &lt;Text&gt;declar, sub
                                          sanctiunile aplicate faptei de fals in acte publice, ca datele din aceasta
                                          declaratie sunt corecte si complete, iar persoana care a intocmit prezenta
                                          declaratie este
                                      &lt;/Text&gt;
                                  &lt;/TextFlow&gt;
                              &lt;/HBox&gt;
                              &lt;HBox&gt;
                                  &lt;Label text="Denumire/nume prenume"/&gt;
                                  &lt;TextField fx:id="denumireIntocmitor"/&gt;
                                  &lt;Label text="CUI/CNP/NIF"/&gt;
                                  &lt;TextField fx:id="cifIntocmitor"/&gt;
                              &lt;/HBox&gt;
                              &lt;HBox&gt;
                                  &lt;Label text="Persoana juridica"/&gt;
                                  &lt;RadioButton fx:id="tipIntocmitorPJ"/&gt;
                                  &lt;Label text="Calitate"/&gt;
                                  &lt;TextField fx:id="calitateIntocmitor"/&gt;
                              &lt;/HBox&gt;
                              &lt;HBox&gt;
                                  &lt;Label text="Persoana fizica"/&gt;
                                  &lt;RadioButton fx:id="tipIntocmitorPF"/&gt;
                                  &lt;Label text="Functia in cadrul persoanei impozabile"/&gt;
                                  &lt;TextField fx:id="functieIntocmitor"/&gt;
                                  &lt;Label text="Alta calitate"/&gt;
                                  &lt;Text text="?????"/&gt;
                                  &lt;!-- @todo ce vine aici? --&gt;
                              &lt;/HBox&gt;
                              &lt;HBox&gt;
                                  &lt;TextFlow&gt;
                                      &lt;Text text="De asemenea, subsemnatul "/&gt;
                                      &lt;Text fx:id="denumireRtext2"/&gt;
                                      &lt;Text text=",in calitate de reprezentant legal "/&gt;
                                      &lt;Text fx:id="functieReprezText"/&gt;
                                      &lt;Text text=" declar:"/&gt;
                                  &lt;/TextFlow&gt;
                              &lt;/HBox&gt;
                              &lt;HBox&gt;
                                  &lt;Text&gt;1. sunt de acord ca, pentru anul fiscal 2016, in sensul prevederilor art. 11 alin
                                      (3) lit. d) din Legea nr. 207/2015 privind Codul de procedura fiscala, datele
                                      inscrise in
                                      prezenta declaratie referitoare la tranzactiile derulate cu fiecare persoana
                                      impozabila (client/furnizor) inregistrata in scopuri de TVA sa fie consultate de
                                      catre aceasta
                                      prin intermediul aplicatiei informatice pusa la dispozitie de ANAF.
                                  &lt;/Text&gt;
                                  &lt;RadioButton fx:id="optinueDA" text="Da"/&gt;
                                  &lt;RadioButton fx:id="optiuneNU" text="Nu"/&gt;
                              &lt;/HBox&gt;
                              &lt;HBox&gt;
                                  &lt;Text&gt;2. Sunt de acord cu schimbarea optiunii , astfel ca pentru anul fiscal 2016, in
                                      sensul prevederilor art. 11 alin (3) lit. d) din Legea nr. 207/2015 privind Codul de
                                      procedura fiscala, datele inscrise in prezenta declaratie referitoare la
                                      tranzactiile derulate cu fiecare persoana impozabila (client/furnizor) inregistrata
                                      in scopuri de
                                      TVA sa fie consultate de catre aceasta prin intermediul aplicatiei informatice pusa
                                      la dispozitie de ANAF
                                  &lt;/Text&gt;
                                  &lt;RadioButton fx:id="schimbOptiuneDA" text="Da"/&gt;
                                  &lt;RadioButton fx:id="schimbOptiuneNU" text="Nu"/&gt;
                              &lt;/HBox&gt;
                          &lt;/VBox&gt;
                      &lt;/Tab&gt;
                  &lt;/TabPane&gt;
              &lt;/Tab&gt;
          &lt;/TabPane&gt;
      &lt;/center&gt;
  
      &lt;bottom&gt;
          &lt;HBox prefHeight="0.0" prefWidth="897.0"&gt;
              &lt;Button onAction="#nextTab" text="Pagina urmatoare"/&gt;
              &lt;Button onAction="#validate" text="Valideaza XML-ul"/&gt;
              &lt;Button onAction="#validateCreate" text="Valideaza XML-ul si creeaza PDF"/&gt;
              &lt;Button onAction="#validateCreateSign" text="Valideaza XML-ul si creeaza PDF semnat"/&gt;
          &lt;/HBox&gt;
      &lt;/bottom&gt;
  &lt;/BorderPane&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wQYz3.png" rel="noreferrer">This is how it ends up looking</a>
  <code>setPrefWidth</code> of the text does nothing</p>
  
  <p>Making the <code>HBox</code>es smaller does make the text wrap, but it ends up on top of text from the other <code>HBox</code>es.</p>
  
  <p>What I want is for my text to wrap to the width of the <code>HBox</code>es which should be at the same size as the parent actual size.</p>
  
  <p>My controller doesn't do anything in terms of styling and layout, and my .css doesn't do anything.</p>
  
  <p>I'm using java8.</p>