CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: splash screen

  1. #1
    Join Date
    Aug 2009
    Posts
    78

    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

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: splash screen

    try this

  3. #3
    Join Date
    Oct 2008
    Posts
    77

    Re: splash screen

    splash comes with java 6
    it is as simple as

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

  4. #4
    Join Date
    Aug 2009
    Posts
    78

    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

  5. #5
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: splash screen

    Quote Originally Posted by inmar32 View Post
    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.

  6. #6
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    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>

  7. #7
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: splash screen

    Quote Originally Posted by keang View Post
    You can include the splash screen image in a jar without using launch4J. The java tutorial says:
    Even better

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

    Experience is a poor teacher: it gives its tests before it teaches its lessons...
    Anon.
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  8. #8
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    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

  9. #9
    Join Date
    Dec 2009
    Posts
    5

    Unhappy 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

  10. #10
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    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.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  11. #11
    Join Date
    Dec 2009
    Posts
    5

    Arrow 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/

  12. #12
    Join Date
    Dec 2009
    Posts
    5

    Re: splash screen

    Quote Originally Posted by keang View Post
    try this
    Hehe, Keang I was actually following your instructions. The links I have posted are amongst the top ones when you google 'java splash screen'

  13. #13
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    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.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  14. #14
    Join Date
    Dec 2009
    Posts
    5

    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

  15. #15
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    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 code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured