This Inline code is working properly, It log's "END ANIMATION" when animation finish.
How do I set a Sub in my application for this Event ?
Many Thanks.
#if java
import javafx.scene.control.*;
import javafx.scene.image.*;
import javafx.scene.transform.Rotate;
import javafx.animation.*;
import javafx.util.Duration;
private static Rotate rotator = new Rotate();
public static void setRotatePoint(ImageView iv,Double angle,Double x,Double y){
// clear transforms
iv.getTransforms().clear();
//rotation
rotator = new Rotate(angle,x,y);
// add rotation to the imageview
iv.getTransforms().add(rotator);
}
public static void animeRotation(ImageView card){
Animation Anime = animeRotator(card);
Anime.play();
}
private static Animation animeRotator(ImageView card) {
RotateTransition Anime = new RotateTransition(Duration.millis(5000), card);
Anime.setAxis(Rotate.X_AXIS);
Anime.setFromAngle(0);
Anime.setToAngle(90);
Anime.setInterpolator(Interpolator.LINEAR);
Anime.setCycleCount(1);
Anime.setOnFinished(event -> {
//this code runs when the animation is complete
System.out.println("END ANIMATION");
});
return new ParallelTransition(card, Anime);
}
#end if
How do I set a Sub in my application for this Event ?
Many Thanks.
#if java
import javafx.scene.control.*;
import javafx.scene.image.*;
import javafx.scene.transform.Rotate;
import javafx.animation.*;
import javafx.util.Duration;
private static Rotate rotator = new Rotate();
public static void setRotatePoint(ImageView iv,Double angle,Double x,Double y){
// clear transforms
iv.getTransforms().clear();
//rotation
rotator = new Rotate(angle,x,y);
// add rotation to the imageview
iv.getTransforms().add(rotator);
}
public static void animeRotation(ImageView card){
Animation Anime = animeRotator(card);
Anime.play();
}
private static Animation animeRotator(ImageView card) {
RotateTransition Anime = new RotateTransition(Duration.millis(5000), card);
Anime.setAxis(Rotate.X_AXIS);
Anime.setFromAngle(0);
Anime.setToAngle(90);
Anime.setInterpolator(Interpolator.LINEAR);
Anime.setCycleCount(1);
Anime.setOnFinished(event -> {
//this code runs when the animation is complete
System.out.println("END ANIMATION");
});
return new ParallelTransition(card, Anime);
}
#end if
Last edited: