我希望此代码在页面中显示黑色圆圈,然后在一秒钟后它应该在页面中显示一个白色圆圈,但它显示一个空白页面,一秒钟后它在页面中显示一个白色圆圈,我该怎么办?
Group group = new Group();
Scene scene = new Scene(group,200,200, Color.LIGHTGREEN);
Circle circle = new Circle(100,100,50);
group.getChildren().add(circle);
stage.setScene(scene);
stage.show();
Thread.sleep(1000);
circle.setFill(Color.WHITE);
stage.show();
答案 0 :(得分:0)
卸下:
Thread.sleep(1000);
circle.setFill(Color.WHITE);
并将其替换为:
Timeline timeline = new Timeline(new KeyFrame(Duration.millis(1000),
ae -> circle.setFill(Color.WHITE)));
timeline.setCycleCount(1);
timeline.play();