This content has been marked as final. Show 1 reply
The syntax "..." in the type of the last parameter of a method (or constructor) indicates 0 or more parameters of that type. It's called "varargs", or more formally a "variable arity parameter". See [url http://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html]Arbitrary numbers of arguments in the Java tutorial, or the [url http://docs.oracle.com/javase/1.5.0/docs/guide/language/varargs.html]description of varargs from release 1.5.0 of the Java language (when varargs were introduced).
A timeline animation is composed of a collection of KeyFrames. Each KeyFrame consists of a Duration (the time on the timeline for that "frame"), zero or more KeyValues, and optionally an EventHandler.
The KeyValues consist of a writable property and a "target value" for that property.
When the timeline animation runs, it "smoothly" changes the values of all the properties that appear in KeyValues. The aim is that for each instant defined by a KeyFrame, the value of any property specified by a KeyValue in that KeyFrame will be equal to the corresponding target value. Values at times in between KeyFrames are interpolated between the times specified by the KeyFrames.
Additionally, when the time on the timeline passes the time specified in that key frame, and event will be fired to the event handler, if there is one.
So your constructor call with a Duration and EventHandler matches the constructor with signature
KeyFrame(Duration, EventHandler, KeyValues...)
with zero KeyValues. This key frame doesn't specify any values to be "targeted" at that moment, but will call the EventHandler's handle(...) method when the corresponding moment on the timeline is passed.
creates a key frame at 500 milliseconds with a target value of 300 for rectBasicTimeline's x property. So the timeline will smoothly change rectBasicTimeline.xProperty from it's initial value at time 0 to 300 over a time period of 500 milliseconds (assuming no other KeyFrames in there).
final KeyValue kv = new KeyValue(rectBasicTimeline.xProperty(), 300); final KeyFrame kf = new KeyFrame(Duration.millis(500), kv);