Solved

How to display Splash Screen in longer time?

Posted on 2003-12-03
7
377 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
  • 4
  • 2
7 Comments
 
LVL 9

Expert Comment

by:yongsing
ID: 9872434
0
 
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
Independent Software Vendors: 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!

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

733 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