Understanding KeyFrame and KeyValue

KeyFrame works tightly with the Duration class, which is responsible for measuring time intervals. The Duration API is straightforward—you choose a time unit, how many of them you need, and how to combine them. See the following examples:

Duration.seconds(5);Duration.hours(1).add(Duration.minutes(15));Duration.valueOf("10ms");new Duration(100); // default unit is millisecondsDuration.ZERO;

For a specified Duration, you can select one or several KeyValue objects. KeyValue takes two parameters—the property you want to set and a value of the corresponding type.

Note that you don't have to set initial values in the first KeyFrame with Duration.ZERO—if they are missing, Timeframe will use the current values ...

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.