javajavafxtextflow

How to remove text from textflow in javafx?


I'm new to javafx and am trying to display large amount of text in textflow. It displays fine, but I just cannot figure out how to delete the text.

So what I'm trying to do is delete all Text nodes from textFlow like so

textFlow.getChildren().removeAll();

But when I do this and add something to textFlow, it shows after the text that was already displayed there. I would like the text that was there removed and show the added text from the beginning of the textflow.

I guess I have to somehow rerender the view of textflow, but I don't know how. So how do I delete everything and add Text anew?


Solution

  • removeAll(...) will remove all the values you pass as parameters: in your case there are none, so it doesn't remove anything. Use

    textFlow.getChildren().clear();