dimanche 17 juillet 2022

How to stop transition when checkbox is unchecked javafx

So I've made a checkbox that applies a scale transition to a rectangle when checked. But the problem is that the transition keeps going even after I uncheck the checkbox. Any ideas on how to make it stop after un-checking?

checkbox.setOnAction(e -> {
            ScaleTransition scaleT = new ScaleTransition(Duration.seconds(5), rectangle);
            scaleT.setAutoReverse(true);
            scaleT.setCycleCount(Timeline.INDEFINITE);
            scaleT.setToX(2);
            scaleT.setToY(2);
            scaleT.play();
        });



Aucun commentaire:

Enregistrer un commentaire