Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to use TextFlow from FXML?

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 13427
303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the JavaFX forum.
 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please follow JavaRanch policy when posting to multiple forums:
https://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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Example

FXML

>

Controller



Main Class

 
Petr Omáčka
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is also crossposted here http://stackoverflow.com/questions/37436595/how-to-use-textflow-from-fxml.
 
John Damien Smith
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic