Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 403
vikiv Avatar asked Nov 20 '25 20:11

vikiv


1 Answers

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();
like image 192
James_D Avatar answered Nov 23 '25 08:11

James_D



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!