Solved

How to display Splash Screen in longer time?

Posted on 2003-12-03
7
369 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now