在JavaFX中显示启动画面

时间:2018-01-29 04:29:42

标签: java javafx

我正在开发一个项目,它需要一个启动画面大约5秒左右,然后进入主程序。到目前为止我所做的事情(不是很有效)是:

    // Create Splash screen
    StackPane base_splashScene = new StackPane();
    ProgressBar pgrBar = new ProgressBar(0);
    BorderPane bdrPane = new BorderPane();
    bdrPane.setBottom(pgrBar);
    base_splashScene.getChildren().add(bdrPane);
    Scene splashScene = new Scene(base_splashScene, 450,350);

    // Load the Splash Scene and start the Primary Stage.
    primaryStage.setTitle("NFL Draft Planner");
    primaryStage.setScene(splashScene);        
    primaryStage.show();

    // wait 5 seconds and update progress bar 10% every half second while I wait.

    // This is the section I am having trouble solving. I keep getting errors because
        I am in the wrong thread or locking up everything for five seconds. I cant
       find a timer that works.

    primaryStage.hide();

    // Load the Scene and show the Primary Stage
    primaryStage.setTitle("Main Program.");
    primaryStage.setScene(Scene()); // Runs method to build the scene.
    primaryStage.show();

0 个答案:

没有答案