r/JavaFX • • Nov 22 '24

Help Creating Delay With JavaFX

Hello! I am studying cs and right now Im programming a little hobby software using JavaFX.

My problem is, I have a long string that is read from a file. I use toCharArray function because what i want to do is append this string character by character to textarea with 20ms delay between characters.

Normally i would use thread.sleep() but it freezes whole program. If someone could point me to a right direction it would be much appreciated.

Thank you in advance!

7 Upvotes

16 comments sorted by

View all comments

Show parent comment

1

u/sedj601 Nov 22 '24

Did you run into issues that caused you to position the caret? Try using textArea.appendText(...) to see if that makes a difference.

2

u/kavedaa Nov 22 '24

No, it was deliberate, to make it look like someone is typing.

But you're right - appendText one character at a time gives the same result, without having to position the caret.