- java.lang.Object
- 
- javafx.animation.KeyFrame
 
- 
 public final class KeyFrame extends Object Defines target values at a specified point in time for a set of variables that are interpolated along aTimeline.The developer controls the interpolation of a set of variables for the interval between successive key frames by providing a target value and an Interpolatorassociated with each variable. The variables are interpolated such that they will reach their target value at the specified time. AnonFinishedfunction is invoked on eachKeyFrameif one is provided. AKeyFramecan optionally have aname, which will result in a cuepoint that is automatically added to theTimeline.- Since:
- JavaFX 2.0
- See Also:
- Timeline,- KeyValue,- Interpolator
 
- 
- 
Constructor SummaryConstructors Constructor Description KeyFrame(Duration time, String name, KeyValue... values)Constructor ofKeyFrameKeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, Collection<KeyValue> values)Constructor ofKeyFrameKeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, KeyValue... values)Constructor ofKeyFrameKeyFrame(Duration time, KeyValue... values)Constructor ofKeyFrameKeyFrame(Duration time, EventHandler<ActionEvent> onFinished, KeyValue... values)Constructor ofKeyFrame
 - 
Method SummaryModifier and Type Method Description booleanequals(Object obj)Indicates whether some other object is "equal to" this one.StringgetName()Returns thenameof thisKeyFrame.EventHandler<ActionEvent>getOnFinished()Returns theonFinishedevent handler of thisKeyFrame.DurationgetTime()Returns the time offset of thisKeyFrame.Set<KeyValue>getValues()Returns an immutableSetofKeyValueinstances.inthashCode()Returns a hash code for thisKeyFrameobject.StringtoString()Returns a string representation of thisKeyFrameobject.
 
- 
- 
- 
Constructor Detail- 
KeyFramepublic KeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, Collection<KeyValue> values) Constructor ofKeyFrameIf a passed in KeyValueisnullor a duplicate, it will be ignored.- Parameters:
- time- the- time
- name- the- name
- onFinished- the- onFinished
- values- a- ObservableListof- KeyValueinstances
- Throws:
- NullPointerException- if- timeis null
- IllegalArgumentException- if- timeis invalid (see- time)
 
 - 
KeyFramepublic KeyFrame(Duration time, String name, EventHandler<ActionEvent> onFinished, KeyValue... values) Constructor ofKeyFrameIf a passed in KeyValueisnullor a duplicate, it will be ignored.- Parameters:
- time- the- time
- name- the- name
- onFinished- the- onFinished
- values- the- KeyValueinstances
- Throws:
- NullPointerException- if- timeis null
- IllegalArgumentException- if- timeis invalid (see- time)
 
 - 
KeyFramepublic KeyFrame(Duration time, EventHandler<ActionEvent> onFinished, KeyValue... values) Constructor ofKeyFrame- Parameters:
- time- the- time
- onFinished- the- onFinished
- values- the- KeyValueinstances
- Throws:
- NullPointerException- if- timeis null
- IllegalArgumentException- if- timeis invalid (see- time)
 
 - 
KeyFramepublic KeyFrame(Duration time, String name, KeyValue... values) Constructor ofKeyFrame- Parameters:
- time- the- time
- name- the- name
- values- the- KeyValueinstances
- Throws:
- NullPointerException- if- timeis null
- IllegalArgumentException- if- timeis invalid (see- time)
 
 - 
KeyFramepublic KeyFrame(Duration time, KeyValue... values) Constructor ofKeyFrame- Parameters:
- time- the- time
- values- the- KeyValueinstances
- Throws:
- NullPointerException- if- timeis null
- IllegalArgumentException- if- timeis invalid (see- time)
 
 
- 
 - 
Method Detail- 
getTimepublic Duration getTime() Returns the time offset of thisKeyFrame. The returnedDurationdefines the time offset within a single cycle of aTimelineat which theKeyValueswill be set and at which theonFinishedfunction variable will be called.The timeof aKeyFramehas to be greater than or equal toDuration.ZEROand it cannot beDuration.UNKNOWN. Note: While the unit oftimeis a millisecond, the granularity depends on the underlying operating system and will in general be larger. For example animations on desktop systems usually run with a maximum of 60fps which gives a granularity of ~17 ms.- Returns:
- the time offset
 
 - 
getValuespublic Set<KeyValue> getValues() Returns an immutableSetofKeyValueinstances. AKeyValuedefines a target and the desired value that should be interpolated at the specified time of thisKeyFrame.- Returns:
- an immutable SetofKeyValueinstances
 
 - 
getOnFinishedpublic EventHandler<ActionEvent> getOnFinished() Returns theonFinishedevent handler of thisKeyFrame. TheonFinishedevent handler is a function that is called when the elapsed time on a cycle passes the specified time of thisKeyFrame. TheonFinishedfunction variable will be called if the elapsed time passes the indicated value, even if it never equaled the time value exactly.- Returns:
- the onFinishedevent handler
 
 - 
getNamepublic String getName() Returns thenameof thisKeyFrame. If a namedKeyFrameis added to aTimeline, a cuepoint with thenameand thetimeof theKeyFramewill be added automatically. If theKeyFrameis removed, the cuepoint will also be removed.- Returns:
- the name
 
 - 
toStringpublic String toString() Returns a string representation of thisKeyFrameobject.
 - 
hashCodepublic int hashCode() Returns a hash code for thisKeyFrameobject.
 
- 
 
-