user550738
user550738

Reputation:

showing Java app splash screen with MANIFEST.MF; is there a way to set minimum on screen time?

I have a Java desktop application in a runnable JAR file. I'm using the MANIFEST.MF file to display a splash screen like so:

Manifest-Version: 1.0
Class-Path: .
Main-Class: MyApp
SplashScreen-Image: images/splash.gif

It works but the splash image is only on screen for a fraction of a second which is too short a time.

Is there a way for me to set the minimum display time for the splash screen? I'd like it to be onscreen for minimum 2 seconds or so.

Upvotes: 0

Views: 1505

Answers (2)

Danish Jahangir
Danish Jahangir

Reputation: 11

Use threading to pause for some time. Use the following code in run():

try{
  Thread.sleep(4000) // where 4000 is milliseconds
} catch(Exception e) {}

Add the above code inside the run method with separate try catch block.

Upvotes: 0

mercutio
mercutio

Reputation: 1066

I do not believe you can change the amount of time that image will be shown.

What you could do is to just create your own implementation of a splash screen. Basically all you need is a Window that displays one image and that loads the rest of your app in the background. When the app has finished loading and more than 2 seconds have passed you can hide the splash and display your main app.

Upvotes: 1

Related Questions