0

I am working on a project and it needs a splash screen up for 5 seconds or so then head into the main program. What I have so far (which doesn't quite work) is:

    // 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();
Makoto
  • 104,088
  • 27
  • 192
  • 230
  • Why don't you use rxjava or something? – jcuypers Jan 29 '18 at 07:06
  • While you're not looking to create a *transparent* background splash screen, after some perusing of the existing comments I feel like this will sufficiently answer your question. – Makoto Jan 29 '18 at 07:09
  • Your problem is probably in the code you don't show, for example, whatever "wait 5 seconds and update progress bar 10% every half second while I wait." does. – jewelsea Jan 29 '18 at 16:06

0 Answers0