Adding cue points

For finer control, you can use cue points for a specific duration:

timeline.playFrom(duration);timeline.jumpTo(duration);timeline.playFrom(cuePoint);timeline.playFromStart();

Here, the cue point is a string; it can be set as a KeyFrame additional parameter:

KeyFrame keyFrame = new KeyFrame(Duration.seconds(5), "cue point 1", keyValue);...timeline.playFrom("cue point 1");

Although cue points are being created in the KeyFrame objects, you can work with them only from the corresponding Timeline, for example, to print all cue points:

// chapter5/basics/CombinedAnimation.javafor (Map.Entry<String, Duration> entry : timeline.getCuePoints().entrySet()) {    System.out.println(entry.getValue() + ": " + entry.getKey());}

Get Mastering JavaFX 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.