Click to See Complete Forum and Search --> : splash screen


inmar32
January 23rd, 2010, 02:13 PM
hey
Does any one know a good guide of creating a simple splash screen in netbeans ?
Even code example can help .

I search the net and never find somthing that work .


thank you

keang
January 23rd, 2010, 05:24 PM
try this (http://www.lmgtfy.com/?q=java+splash+screen)

postmortem
January 24th, 2010, 06:50 PM
splash comes with java 6
it is as simple as

java -splash:filename.gif -jar SplashTest yourbuild.jar

inmar32
January 26th, 2010, 12:36 PM
I wanted the splash to be in the jar.
I found a great free software the helped me with it - launch4j .

thanks

dlorde
January 27th, 2010, 06:29 AM
I wanted the splash to be in the jar.

It would have been helpful if you'd said so.

I found a great free software the helped me with it - launch4j

Thanks for the heads-up :thumb:

Don't worry about people stealing your ideas. If your ideas are any good, you'll have to ram them down people's throats...
H. Aiken

keang
January 27th, 2010, 08:46 AM
You can include the splash screen image in a jar without using launch4J. The java tutorial says:

How to Use a JAR File to Display Splash Screen

If your application is packaged in a JAR file, you can use the SplashScreen-Image option in a manifest file to show a splash screen. Place the image in the JAR file and specify the path in the option as follows:
Manifest-Version: 1.0
Main-Class: <class name>
SplashScreen-Image: <image name>

dlorde
January 27th, 2010, 02:01 PM
You can include the splash screen image in a jar without using launch4J. The java tutorial says:

Even better :thumb::thumb:

Silly me, I just assumed the OP would have read the tutorial... :rolleyes:

Experience is a poor teacher: it gives its tests before it teaches its lessons...
Anon.

keang
January 28th, 2010, 11:16 AM
Silly me, I just assumed the OP would have read the tutorial...Well it was half way down the page of the first link that appeared from the let-me-google-that-for-you link I provided :rolleyes:

Mather
February 25th, 2011, 02:12 PM
I just tried using the manifest option for my jar file and can't understand why it's not working...

I have a "SplashFrame.java" file in a directory "uk.co.basilios.easel.splashscreen".

SplashFrame.java



import java.awt.*;

public class SplashFrame extends Frame {

public static void renderSplashFrame(Graphics2D g, int frame) {
final String[] comps = {"The program is starting up", "Hang on!", "Almost there..."};
g.setComposite(AlphaComposite.Clear);
g.fillRect(130,250,280,40);
g.setPaintMode();
g.setColor(Color.BLACK);
g.drawString("Loading "+comps[(frame/5)%3]+"...", 130, 260);
g.fillRect(130,270,(frame*10)%280,20);
}


public SplashFrame() {

final SplashScreen splash = SplashScreen.getSplashScreen();
if (splash == null) {
System.out.println("SplashScreen.getSplashScreen() returned null");
return;
}
Graphics2D g = (Graphics2D)splash.createGraphics();
if (g == null) {
System.out.println("g is null");
return;
}
for(int i=0; i<100; i++) {
renderSplashFrame(g, i);
splash.update();
try {
Thread.sleep(200);
}
catch(InterruptedException e) {
}
}
splash.close();
}


public static void main (String args[]) {
SplashFrame test = new SplashFrame();
}
}



In my main class, I have added this bit:



import uk.co.basilios.easel.splashscreen.*;

....


public static void splashGraphics() {

SplashFrame mysplash = new SplashFrame();
}



And my manifest looks like this:



Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 11.0-b15 (Sun Microsystems Inc.)
Main-Class: uk.co.basilios.easel.Main
Class-Path: lib/iText-2.1.3.jar lib/vecmath.jar lib/AbsoluteLayout.jar lib/Canvas_Compiler.jar
X-COMMENT: Main-Class will be added automatically by build
SplashScreen-Image: uk/co/basilios/splashscreen/images/splash.gif

keang
February 25th, 2011, 05:35 PM
I just tried using the manifest option for my jar file and can't understand why it's not working...Can you be more precise - what did you expect it to do and what exactly is not working?

I have a "SplashFrame.java" file in a directory "uk.co.basilios.easel.splashscreen".Now I'm lost, what has this got to do with a the jar file SplashScreen-Image setting. This jar file setting just displays the specified image file until the first window opens.

Mather
February 27th, 2011, 05:49 AM
Sorry, I assumed you would have read the previous messages in the thread. The manifest option is described here: http://download.oracle.com/javase/tutorial/uiswing/misc/splashscreen.html under "How to Use a JAR File to Display Splash Screen".

From my understanding (which is not necessarily correct), the manifest creates the splash screen whereas SplashFrame.java adds dynamic information to the splash screen class- so in my case, a graphical overlay which will show the progress bar.

Make sense?
If not, this article explains it pretty well: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/splashscreen/

Mather
February 27th, 2011, 05:52 AM
try this (http://www.lmgtfy.com/?q=java+splash+screen)

Hehe, Keang I was actually following your instructions. The links I have posted are amongst the top ones when you google 'java splash screen' :p

keang
February 27th, 2011, 06:52 AM
Hehe, Keang I was actually following your instructions.To be fair my original post was advising on how to display a simple splash screen. I didn't even know you could get access to the splash screen - it appears this class was added in Java 1.6 and I hadn't noticed it. But thanks for pointing this out as I could use feature this myself.

You still haven't said what is actually happening and what you expected.

One thing I've noticed is your jar file is starting the class uk.co.basilios.easel.Main. Is this class calling your SplashFrame class.

Mather
February 28th, 2011, 10:08 AM
Yep, the Main class is calling the SplashFrame class.

The problem seems to be in the SplashFrame class- command prompt is outputting "SplashScreen.getSplashScreen() returned null" when the JAR file is run.

What I'm expecting to happen is the splash screen comes up, with the progress bar updating and then my program opens up. What is actually happening is my program opens up without the splash screen.

Incidentally, when I try to use the Command-Line Argument to Display a Splash Screen option, I get the following error:


Main.java:96: cannot access SplashFrame
bad class file: .\SplashFrame.class
class file contains wrong class: uk.co.basilios.easel.splashscreen.SplashFrame
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
SplashFrame mysplash = new SplashFrame();
^
1 error


:s

keang
February 28th, 2011, 10:44 AM
The problem seems to be in the SplashFrame class- command prompt is outputting "SplashScreen.getSplashScreen() returned null" when the JAR file is run.That's the important piece of information I was after. If your code is outputting that text then it is never even going to try to draw the progress bar because A) there's nothing for it to draw on and B) Your code correctly returns immediately after printing the statement so the progress bar drawing code won't ever get executed.

You need to establish why you are getting a null return value. The java docs say the method "Returns: the SplashScreen instance, or null if there is none or it has already been closed".

So, given that you can see the splash screen, it must be closing before your code is being executed. Remember the splash screen is closed automatically as soon as the first Swing/AWT window is displayed.

Incidentally, when I try to use the Command-Line Argument to Display a Splash Screen option, I get the following error:Are you specifying the correct classpath?

Mather
March 1st, 2011, 05:35 AM
Thank you so much Keang- problem solved!

The manifest was the culprit- I changed the code so that it now says:


Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 11.0-b15 (Sun Microsystems Inc.)
Main-Class: uk.co.basilios.easel.Main
Class-Path: lib/iText-2.1.3.jar lib/vecmath.jar lib/AbsoluteLayout.jar lib/Canvas_Compiler.jar
X-COMMENT: Main-Class will be added automatically by build
SplashScreen-Image: splash.gif




And created the JAR file with "jar cmf manifest.txt File.jar lib* uk* splash.gif"

:)