package sample; 

import javafx.animation.Animation; 
import javafx.animation.RotateTransition; 
import javafx.animation.TranslateTransition; 
import javafx.application.Application; 

import javafx.scene.Node; 
import javafx.scene.Scene; 
import javafx.scene.control.Label; 
import javafx.scene.layout.StackPane; 
import javafx.stage.Stage; 
import javafx.util.Duration; 


public class Demo extends Application { 
    @Override 
    public void start(Stage stage) throws Exception { 
        Label l = new Label("A"); 
        StackPane sp = new StackPane(l); 
        stage.setScene(new Scene(sp, 200, 200)); 
        stage.show(); 
        addTranslate(l); 
        // addRotate(l); // uncomment to test with rotate 

    } 

    private void addRotate(Node target) { 
        RotateTransition rt = new RotateTransition(Duration.millis(3000), target); 
        rt.setToAngle(360); 
        rt.setCycleCount(Animation.INDEFINITE); 
        rt.play(); 
    } 

    private void addTranslate(Node target) { 
        TranslateTransition tt = new TranslateTransition(Duration.millis(3000), target); 
        tt.setByX(50); 
        tt.setAutoReverse(true); 
        tt.setCycleCount(Animation.INDEFINITE); 
        tt.play(); 
    } 

    public static void main(String[] args) { 
        launch(args); 
    } 

} package sample; 

import javafx.animation.Animation; 
import javafx.animation.RotateTransition; 
import javafx.animation.TranslateTransition; 
import javafx.application.Application; 

import javafx.scene.Node; 
import javafx.scene.Scene; 
import javafx.scene.control.Label; 
import javafx.scene.layout.StackPane; 
import javafx.stage.Stage; 
import javafx.util.Duration; 


public class Demo extends Application { 
    @Override 
    public void start(Stage stage) throws Exception { 
        Label l = new Label("A"); 
        StackPane sp = new StackPane(l); 
        stage.setScene(new Scene(sp, 200, 200)); 
        stage.show(); 
        addTranslate(l); 
        // addRotate(l); // uncomment to test with rotate 

    } 

    private void addRotate(Node target) { 
        RotateTransition rt = new RotateTransition(Duration.millis(3000), target); 
        rt.setToAngle(360); 
        rt.setCycleCount(Animation.INDEFINITE); 
        rt.play(); 
    } 

    private void addTranslate(Node target) { 
        TranslateTransition tt = new TranslateTransition(Duration.millis(3000), target); 
        tt.setByX(50); 
        tt.setAutoReverse(true); 
        tt.setCycleCount(Animation.INDEFINITE); 
        tt.play(); 
    } 

    public static void main(String[] args) { 
        launch(args); 
    } 

} 