用多线程!!!比如:/*
* (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!" );
}
}
* (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!" );
}
}
解决方案 »
- 给定两个字符串s和t,请判断s是否是t的子序列
- ClassNotFoundException 求助
- 给学Java的大学生们分享一些经验(六)--Java杂谈J2se部分最后一篇
- 大家来看看 这个现象好奇怪
- eclipse运行时只停留在启动界面,这是为什么??
- 求JAVA核心技术1,2卷,要最新版的,是最新版的(6版(不包括)以上的),100分给第一个有效的提供者,行动吧朋友们!
- 请看看我的毕业设计(产业信息资源库)的需求分析中的功能分析。
- 我的JB老出错,请帮忙看看,一定加分
- 用JAVAMAIL发送多媒体信息,关于MMS的应用
- 请问你们新建Java项目的时候项目名怎么填?
- 这样的switch语句该怎么写?
- 紧急求助:JNI中如何改变JAVA中的线程堆栈?
{
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();
}
}
{
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();
}
}这样就可以了!哈哈!