tags:

views:

21

answers:

1

I'd like to print a longer text letter by letter - as if someone is just typing it on a typewriter. What's the best approach here in JavaFX?

A: 

You'll just need to take a string and then lay it out letter-by-letter on to the scene to simulate a typewriter typing. Iterate over the string and maybe increment an x,y position of the current letter to get it in place on the screen. Take a look at the TimeLine object in the JavaFX 1.3 api, at each "tick" of the timeline you can write a new letter out.
A small random delay will make the layout appear more like typing (look at PauseTransition - which executes an action after a given delay - this could be bound to a var set randomly at each tick).

Hope this helps. Feel free to post it back here or to somewhere like jfxstudio.org when you get it working.

Matthew Hegarty