用多线程!!!比如:/*
 * (c) Copyright IBM Corp. 2000, 2001.
 * All Rights Reserved.
 */
 
// This is a sample program to test the eclipse launcher.
// The program looks for the "-endsplash" argument and its
// command string. To simulate initialization, the program
// sleeps for 10 seconds.
package org.eclipse.core.launcher;import java.io.*;
public class Main {private static String splashCmd = null;public static void main( String args[] ) {    System.out.println( "Eclipse: Program started." );    // Extract the command to end the splash window. 
    for (int index = 0; index < args.length; index++)
    {
        System.out.println( "    args[" + index + "] = '" + args[index] + "'" );
        if (args[ index ].equals( "-endsplash" ) && (index+1) < args.length)
        {
            splashCmd = args[ index + 1 ];
        }
    }    // Perform the initialization of eclipse.
    try {
        Thread.sleep( 5000 );
    }
    catch (Exception e) {}
    System.out.println( "Eclipse: Initialization complete!" );    // Initialization is complete so execute the end splash command.
    if (splashCmd != null) {
        try {
            Runtime.getRuntime().exec( splashCmd );
        }
        catch (Exception e) {}
    }    // Perform the actual work of eclipse.
    try {
        Thread.sleep( 10000 );
    }
    catch (Exception e) {}
    System.out.println( "Eclipse: Program is terminating!" );
}
}

解决方案 »

  1.   

    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();
                                // 能够捕获InvocationTargetException
                                // 能够捕获InterruptedException
                            }
                    }
                };
            setVisible(true);
            Thread splashThread = new Thread(waitRunner, "SplashThread");
            splashThread.start();
        }
    }
      

  2.   

    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();
                                // 能够捕获InvocationTargetException
                                // 能够捕获InterruptedException
                            }
                    }
                };
            setVisible(true);
            Thread splashThread = new Thread(waitRunner, "SplashThread");
            splashThread.start();
        }
    }这样就可以了!哈哈!