所以我需要为 ProgressIndicator/Bar 制作一个计时器。我用时间线制作了“动画”,但我不知道如何更改 ProgressIndicator 的颜色?
private ProgressIndicator progress = new ProgressIndicator();
private Timeline timeline = new Timeline();
public void doTime(int sec){
Timeline time = new Timeline(
new KeyFrame(
Duration.ZERO,
new KeyValue(progress.progressProperty(), 1)
),
new KeyFrame(
Duration.seconds(sec),
new KeyValue(progress.progressProperty(), 0)
)
);
time.setCycleCount(1);
time.play();
}
如果进度为 0.33,我想要红色。我没有找到任何进展的听众。
if (progress.getProgress() <= 0.33) {
progress.setStyle("-fx-progress-color: red;");
}
您对如何实现这一点有任何想法吗?