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
Printable View
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
try this
splash comes with java 6
it is as simple as
java -splash:filename.gif -jar SplashTest yourbuild.jar
I wanted the splash to be in the jar.
I found a great free software the helped me with it - launch4j .
thanks
It would have been helpful if you'd said so.
Thanks for the heads-up :thumb:Quote:
I found a great free software the helped me with it - launch4j
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
You can include the splash screen image in a jar without using launch4J. The java tutorial says:
Quote:
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>
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:Quote:
Silly me, I just assumed the OP would have read the tutorial...
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
In my main class, I have added this bit:Code:
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();
}
}
And my manifest looks like this:Code:
import uk.co.basilios.easel.splashscreen.*;
....
public static void splashGraphics() {
SplashFrame mysplash = new SplashFrame();
}
Code:
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
Can you be more precise - what did you expect it to do and what exactly is not working?Quote:
I just tried using the manifest option for my jar file and can't understand why it's not working...
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.Quote:
I have a "SplashFrame.java" file in a directory "uk.co.basilios.easel.splashscreen".
Sorry, I assumed you would have read the previous messages in the thread. The manifest option is described here: http://download.oracle.com/javase/tu...ashscreen.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/techni.../splashscreen/
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.Quote:
Hehe, Keang I was actually following your instructions.
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.
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
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.Quote:
The problem seems to be in the SplashFrame class- command prompt is outputting "SplashScreen.getSplashScreen() returned null" when the JAR file is run.
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.
Are you specifying the correct classpath?Quote:
Incidentally, when I try to use the Command-Line Argument to Display a Splash Screen option, I get the following error: