Solved

How to display Splash Screen in longer time?

Posted on 2003-12-03
7
378 Views
Last Modified: 2010-03-31
How to display a splash screen in a longer time? such as in 10 seconds time.... Thank you!

Code:
*********************************
 public static void main( String[] args )
{
    String baseDir="";
    if(args.length>0){ baseDir=args[0]; }
    splashScreen = new SplashScreen(10);
    splashScreen.dispose();
    Bella bella= new bella();
}
0
Comment
Question by:lotus03
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 75 total points
ID: 9872437
Start a thread to dispose it, something like:

 public static void main( String[] args )
{
    String baseDir="";
    if(args.length>0){ baseDir=args[0]; }
    splashScreen = new SplashScreen(10);
    new Thread(new Runnable() { public void run()
    {
       try { Thread.sleep(10000); } catch (Exception ex) {}
       splashScreen.dispose();
    }}).start();
    Bella bella= new bella();
}
0
 
LVL 15

Expert Comment

by:Javatm
ID: 9872453
Pretty Fast Guys;

Here are my share :

class SplashWindow3 extends JWindow
{
    public SplashWindow3(String filename, Frame f, int waitTime)
    {
        super(f);
        JLabel l = new JLabel(new ImageIcon(filename));
        getContentPane().add(l, BorderLayout.CENTER);
        pack();
        Dimension screenSize =
          Toolkit.getDefaultToolkit().getScreenSize();
        Dimension labelSize = l.getPreferredSize();
        setLocation(screenSize.width/2 - (labelSize.width/2),
                    screenSize.height/2 - (labelSize.height/2));
        addMouseListener(new MouseAdapter()
            {
                public void mousePressed(MouseEvent e)
                {
                    setVisible(false);
                    dispose();
                }
            });
        final int pause = waitTime;
        final Runnable closerRunner = new Runnable()
            {
                public void run()
                {
                    setVisible(false);
                    dispose();
                }
            };
        Runnable waitRunner = new Runnable()
            {
                public void run()
                {
                    try
                        {
                            Thread.sleep(pause);
                            SwingUtilities.invokeAndWait(closerRunner);
                        }
                    catch(Exception e)
                        {
                            e.printStackTrace();
                            // can catch InvocationTargetException
                            // can catch InterruptedException
                        }
                }
            };
        setVisible(true);
        Thread splashThread = new Thread(waitRunner, "SplashThread");
        splashThread.start();
    }
}

0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 15

Expert Comment

by:Javatm
ID: 9872460
>> Thread.sleep(pause);

Give a interval something like 1000

Hope it helps . . .
Javatm
0
 
LVL 9

Expert Comment

by:yongsing
ID: 9872494
Javatm, you copied from the article that I gave!
0
 
LVL 15

Expert Comment

by:Javatm
ID: 9872517
I dont think so, I've researched it here on EE,
before you post it I already seen it. So I added it.
Sorry if I paste it friend :)
0
 
LVL 15

Expert Comment

by:Javatm
ID: 9872526
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question