Skip to content
Advertisement

How do I add a Splash screen to a main program in javafx?

I have 2 files, Splash.java and Main.java. Here are the 2 codes: Splash.java

JavaScript

And Main.java

JavaScript

Now I want to make a Splash screen appear before the main program is launched. How do I modify Main.java so that my code can show the splash screen for its entire duration before fading away and opening the main program?

Advertisement

Answer

I made a few changes to your code. I changed the Splash variable to Scene. I then added methods to get the Scene and the SequentialTransition. I set the SequentialTransition onFinished method in the main. .

Main

JavaScript

Splash Class

JavaScript

After Splash Controller

JavaScript

After Splash FXML

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement