CeciliA CeciliA - 2 months ago 8
Java Question

How to add Splash Screen on a Project that runs normally if you make it a JAR file

My problem guys is if im adding splash screen on netbeans. There`s an error if you build the project to make it a JAR file. Is there a way for me to add a Splash Screen that works in a JAR file? Thanks in Advance guys.

Here is my Property Panel

enter image description here

Answer

You need to add it to the manifest.mf file above the line:

 X-COMMENT: Main-Class will be added automatically by build

Then leave it up for a while in main method if you want:

 SplashScreen splash = SplashScreen.getSplashScreen();
 if(splash != null)
 {
    try 
    {                
        Thread.sleep(2000); //Leave Splash up for 2 seconds
        splash.close();
    }
    catch(InterruptedException e) { LOG.log(Level.INFO, "Spash Sleep Interrupted", e); }
 }
 else
 {
    LOG.info("Splash Screen is null");
 }

Or do something in another thread while main sleeps

Comments