我想每隔5分钟左右按照下面的代码重绘我的场景,不知道如何做到这一点。请记住,当我打电话来绘制image_pane()时,它会经历一个复杂的程序和计算。因此,当我想重绘我的场景时,它必须再次调用此函数..
public void start(Stage stage) {
Pane root = new Pane();
Scene scene = new Scene(root, 1280, 1024);
scene.getStylesheets().addAll(this.getClass().getResource("style.css").toExternalForm());
stage.setScene(scene);
GridPane Mainpane = Main_pane();
GridPane image_pane = image_pane();
Mainpane.add(image_pane, 2, 4,9,8);
scene.setRoot(Mainpane);
stage.show();
}
更新
public GridPane image_pane(){
Subpane = new GridPane();
String image = JavaFXApplication3.class.getResource("/Images/mussalah_old.png").toExternalForm();
Subpane.setStyle("-fx-background-image: url('" + image + "'); -fx-background-image-repeat: no-repeat;");
Subpane.setGridLinesVisible(true);
for(i=0; i<=total_donnation; i++)
{
File blink_file = new File("blink.png");
Image blink_image1 = new Image(blink_file.toURI().toString());
ImageView blink_image = new ImageView(blink_image1);
blink_image.setFitWidth(image_Width);
blink_image.setPreserveRatio(true);
HBox hBox_outter = new HBox();
String style_outter = "-fx-border-color: white;" + "-fx-border-width: 0;";
hBox_outter.setStyle(style_outter);
hBox_outter.getChildren().add(image_tile1);
HBox hBox_outter_last = new HBox();
hBox_outter_last.setStyle(style_outter);
hBox_outter_last.getChildren().add(blink_image);
FadeTransition ft1 = new FadeTransition(Duration.millis(500), hBox_outter_last);
ft1.setFromValue(1.0);
ft1.setToValue(0.3);
ft1.setCycleCount(Animation.INDEFINITE);
ft1.setAutoReverse(true);
ft1.play();
grid_pane1.add(hBox_outter, current_column_pane1,current_row_pane1);
current_row_pane1 = current_row_pane1+1;
if (current_row_pane1 == max_rows_pane1 )
{
current_column_pane1 = current_column_pane1+1;
current_row_pane1 = 0;
}
if (i == max_donnation_pane1 ){ System.out.println("Pane 1 full"); break;}
if (i == total_donnation)
{
if (i != max_donnation_pane1)
{
grid_pane1.add(hBox_outter_last, current_column_pane1,current_row_pane1);
}
}
}
Subpane.add(grid_pane1,3,9,13,14);
Subpane.setId("prayertime_pane");
return Subpane;
}