Click here to Skip to main content
15,889,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need some help regarding in generating splash screen in gui and after the progress,a sample form will display.I have a codes in generating splash screen but my problem is,it doesn't work.In regards to the source codes of a said splash screen there's no function that will call the form after the progress.Anybody could help me regarding to my problem and there's any source codes pertaining to this.I hope you can help me!Thanks.
Posted
Updated 8-Jan-10 16:41pm
v2

There are a couple of approaches you can take:
1:kick off the splash screen in a thread, init, close splash, open sample
2:display the splash (not with run), init, close splash, open sample
The first lets stuff happen in the splash screen, the second would require calls to process windows events in the init code for things to happen in the init screen. I'd kick off the thread myself.
What language are you using?
What does your current code look like?
 
Share this answer
 
wrote:
I have a codes in generating splash screen but my problem is,it doesn't work.In regards to the source codes of a said splash screen there's no function that will call the form after the progress.Anybody could help me


How possibly anyone answer this vague query?!

See how to ask questions the smart way[^]

This might help you as well: Sun Java Documentation: How to create a splash screen[^]
 
Share this answer
 
//Here is the code in generating splash screen...

import java.awt.*;
import java.awt.event.*;

public class SplashDemo extends Frame implements ActionListener {
    static void renderSplashFrame(Graphics2D g, int frame) {
        final String[] comps = {"foo", "bar", "baz"};
        g.setComposite(AlphaComposite.Clear);
        g.fillRect(120,140,200,40);
        g.setPaintMode();
        g.setColor(Color.BLACK);
        g.drawString("Loading "+comps[(frame/5)%3]+"...", 120, 150);
    }
    public SplashDemo() {
        super("SplashScreen demo");
        setSize(300, 200);
        setLayout(new BorderLayout());
        Menu m1 = new Menu("File");
        MenuItem mi1 = new MenuItem("Exit");
        m1.add(mi1);
        mi1.addActionListener(this);
        this.addWindowListener(closeWindow);

        MenuBar mb = new MenuBar();
        setMenuBar(mb);
        mb.add(m1);
        final SplashScreen splash = SplashScreen.getSplashScreen();
        if (splash == null) {
            System.out.println("SplashScreen.getSplashScreen() returned null");
            return;
        }
        Graphics2D g = 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(90);
            }
            catch(InterruptedException e) {
            }
        }
        splash.close();
        setVisible(true);
        toFront();
    }
    public void actionPerformed(ActionEvent ae) {
        System.exit(0);
    }
    
    private static WindowListener closeWindow = new WindowAdapter(){
        public void windowClosing(WindowEvent e){
            e.getWindow().dispose();
        }
    };
    
    public static void main (String args[]) {
        SplashDemo test = new SplashDemo();
    }
}

The problem is,the image returns null.And I'm using GUI in java.Please help me regarding to this.Thank you!
 
Share this answer
 
v2
I notice that your code was copied from here[^]. I suggest you go back and read through the documentation to ensure that your implementation matches what you copied, and also that the code is correct in the first place.

Hint: You may need to include an image file for your SplashScreen
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900