• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use TextFlow from FXML?

 
Petr Omáčka
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use TextFlow coming from FXML but no text is shown.

I have tried:

textflow.getChildren.add(text);

and also:

textflow=new TextFlow(text);

where text is:

Text text=new Text("AAA");

I both cases TextFlow shows nothing.

Is there another container for use with rich text using FXML JavaFX app?

For sure if I try both cases in non-FXML JavaFX app it works both of them.
 
Stephan van Hulst
Bartender
Pie
Posts: 6503
83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the JavaFX forum.
 
John Damien Smith
Ranch Hand
Posts: 296
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please follow JavaRanch policy when posting to multiple forums:
http://www.coderanch.com/t/660346/Wiki/Forthright-Cross-Posting-Sites
https://community.oracle.com/thread/3933717
 
Petr Omáčka
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Example

FXML

>

Controller



Main Class

 
Petr Omáčka
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is also crossposted here http://stackoverflow.com/questions/37436595/how-to-use-textflow-from-fxml.
 
John Damien Smith
Ranch Hand
Posts: 296
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
User Khaled SAB solved your problem on StackOverflow: http://stackoverflow.com/a/37437608/1155209

In your controller class inside the initialize method you are loosing the reference to the old txtF object declared in your FXML by instantiating a new TextFlow object with the same name, and you are not adding this new object to your AnchorPane. So you'll need to remove this line txtF=new TextFlow(new Text("aaa"));
 
Petr Omáčka
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Damien Smith wrote:User Khaled SAB solved your problem on StackOverflow: http://stackoverflow.com/a/37437608/1155209

In your controller class inside the initialize method you are loosing the reference to the old txtF object declared in your FXML by instantiating a new TextFlow object with the same name, and you are not adding this new object to your AnchorPane. So you'll need to remove this line txtF=new TextFlow(new Text("aaa"));


Yes, he does.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic