Removes an animated color from this JavaFX node, if one has been set on it. - Java JavaFX

Java examples for JavaFX:Animation

Description

Removes an animated color from this JavaFX node, if one has been set on it.

Demo Code


//package com.java2s;

import javafx.animation.Timeline;

import javafx.scene.Node;

public class Main {
    private static final String TIMELINE_KEY = "color-animation-utils-timeline";

    /**/*from w  w  w. j  a  v a2 s  .c om*/
     * Removes an animated color from this node, if one has been set on it.
     */
    public static void removeAnimation(final Node node) {

        // Stopping the timeline should allow object properties that depend on it to be garbage collected.
        if (node.getProperties().get(TIMELINE_KEY) instanceof Timeline) {
            final Timeline timeline = (Timeline) node.getProperties().get(
                    TIMELINE_KEY);
            timeline.stop();
        }
    }
}

Related Tutorials