import com.sun.javafx.tk.TKPulseListener; import com.sun.javafx.tk.Toolkit; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ProgressIndicator; import javafx.scene.control.ToggleButton; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class ProgressIndicatorAnim extends Application { private int tickCount = 0; private final TKPulseListener listener = () -> System.err.println("pulse: " + (++tickCount)); @Override public void start(Stage stage) { stage.setTitle("ProgressIndicator Animation"); VBox root = new VBox(); Scene scene = new Scene(root, 600, 450); ProgressIndicator pInd2 = new ProgressIndicator(); pInd2.setPrefSize(50, 50); pInd2.setLayoutX(25); pInd2.setLayoutY(40); pInd2.setVisible(true); ProgressIndicator pInd1 = new ProgressIndicator(); pInd1.setPrefSize(150, 150); pInd1.setLayoutX(200); pInd1.setLayoutY(20); pInd1.setProgress(0.25f); pInd1.setVisible(true); Button removeButton = new Button("Remove Progress"); removeButton.setOnAction(e -> { root.getChildren().remove(pInd2); }); ToggleButton toggleProgressButton = new ToggleButton("Toggle Progress"); toggleProgressButton.setOnAction(e -> { if (toggleProgressButton.isSelected()) { pInd2.setProgress(1.0); } else { pInd2.setProgress(-1); } }); root.getChildren().addAll(removeButton, toggleProgressButton, pInd1, pInd2); stage.setScene(scene); stage.show(); Toolkit.getToolkit().addSceneTkPulseListener(listener); } public static void main(String[] args) { Application.launch(args); } }