Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8164725

Provide a simplified convenience KeyFrame constructor

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • javafx
    • None

      When instantiating timelines, this is usually done with a series of key frames. However, the creation of each key frame requires the instantiation of both a KeyFrame, a Duration, and a KeyValue object, like this
      new Timeline(
          new KeyFrame(new Duration(100), new KeyValue(sendingLabel.opacityProperty(), 1.0)),
          new KeyFrame(new Duration(800), new KeyValue(sendingLabel.opacityProperty(), 0.0))
      );
      I recommend this is simplified by introducing 1 additional constructor in KeyFrame, which will allow me to write the code above as follows:
      new Timeline(
          new KeyFrame(100, sendingLabel.opacityProperty(), 1.0),
          new KeyFrame(800, sendingLabel.opacityProperty(), 0.0)
      );
      I hope it is evident to the reader, that this involves much less typing and is easier to learn, easier to read, and less expensive to maintain.

            nlisker Nir Lisker
            risaksen Randahl Isaksen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: