title: How to use TextFlow from FXML?
body: <p>Crossposted:</p>
  
  <p>• <a href="https://community.oracle.com/message/13853226#13853226" rel="nofollow">https://community.oracle.com/message/13853226#13853226</a></p>
  
  <p>• <a href="http://www.coderanch.com/t/666101/JavaFX/java/TextFlow-FXML#3105251" rel="nofollow">http://www.coderanch.com/t/666101/JavaFX/java/TextFlow-FXML#3105251</a></p>
  
  <p>I am trying to use TextFlow coming from FXML in controller during app execution (not at start-up) but no text is shown.</p>
  
  <p>I have tried:</p>
  
  <pre><code>textflow.getChildren.add(text);
  </code></pre>
  
  <p>and also:</p>
  
  <pre><code>textflow=new TextFlow(text);
  </code></pre>
  
  <p>where text is:</p>
  
  <pre><code>Text text=new Text("AAA");
  </code></pre>
  
  <p>I both cases TextFlow shows nothing.</p>
  
  <p>Is there another container for use with rich text using FXML JavaFX app?</p>
  
  <p>For sure if I try both cases in non-FXML JavaFX app it works both of them.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>TextFlow in FXML looks like this</p>
  
  <pre><code>&lt;TextFlow fx:id="txtFlow" layoutX="20.0" layoutY="230.0" prefHeight="70.0" prefWidth="430.0" style="-fx-border-color: ADD9E6;" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="140.0"&gt;
  </code></pre>
  
  <p>FXML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import java.lang.*?&gt;
  &lt;?import java.util.*?&gt;
  &lt;?import javafx.scene.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import javafx.scene.text.TextFlow?&gt;
  
  &lt;AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" fx:controller="testfxmlpackage.FXMLDocumentController"&gt;
      &lt;children&gt;
          &lt;TextFlow fx:id="txtF" layoutX="22.0" layoutY="234.0" prefHeight="74.0" prefWidth="433.0" style="-fx-border-color: ADD8E6;" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="22.0" AnchorPane.rightAnchor="142.0" /&gt;               
      &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>package testfxmlpackage;
  
  import java.net.URL;
  import java.util.ResourceBundle;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.text.Text;
  import javafx.scene.text.TextFlow;
  
  public class FXMLDocumentController implements Initializable {  
  
    @FXML TextFlow txtF;  
  
    @Override
    public void initialize(URL url, ResourceBundle rb) {
      txtF=new TextFlow(new Text("aaa"));
      txtF.getChildren().add(new Text("aaa"));
    }    
  } 
  </code></pre>
  
  <p>Main Class </p>
  
  <pre><code>package testfxmlpackage;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  public class TestFXMLPackage extends Application {
  
    @Override
    public void start(Stage stage) throws Exception {
      Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
  
      Scene scene = new Scene(root);
  
      stage.setScene(scene);
      stage.show();
    }
  
    public static void main(String[] args) {
      launch(args);
    }  
  }
  </code></pre>