-
January 23rd, 2010, 03:13 PM
#1
splash screen
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
-
January 23rd, 2010, 06:24 PM
#2
-
January 24th, 2010, 07:50 PM
#3
Re: splash screen
splash comes with java 6
it is as simple as
java -splash:filename.gif -jar SplashTest yourbuild.jar
-
January 26th, 2010, 01:36 PM
#4
Re: splash screen
I wanted the splash to be in the jar.
I found a great free software the helped me with it - launch4j .
thanks
-
January 27th, 2010, 07:29 AM
#5
Re: splash screen
Originally Posted by inmar32
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
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
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
January 27th, 2010, 09:46 AM
#6
Re: splash screen
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>
-
January 27th, 2010, 03:01 PM
#7
Re: splash screen
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
-
January 28th, 2010, 12:16 PM
#8
Re: splash screen
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
-
February 25th, 2011, 03:12 PM
#9
Re: splash screen
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
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();
}
}
In my main class, I have added this bit:
Code:
import uk.co.basilios.easel.splashscreen.*;
....
public static void splashGraphics() {
SplashFrame mysplash = new SplashFrame();
}
And my manifest looks like this:
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
-
February 25th, 2011, 06:35 PM
#10
Re: splash screen
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.
-
February 27th, 2011, 06:49 AM
#11
Re: splash screen
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/
-
February 27th, 2011, 06:52 AM
#12
Re: splash screen
Originally Posted by keang
Hehe, Keang I was actually following your instructions. The links I have posted are amongst the top ones when you google 'java splash screen'
-
February 27th, 2011, 07:52 AM
#13
Re: splash screen
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.
-
February 28th, 2011, 11:08 AM
#14
Re: splash screen
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
-
February 28th, 2011, 11:44 AM
#15
Re: splash screen
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?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|