在一个线程中
try{ Thread.sleep(<your_time>);
}catch(Exception e){}
<frame_to_close>.setVisible(false);
<frame_to_show> = new ...;
<frame_to_show>.setVisible(true);
try{ Thread.sleep(<your_time>);
}catch(Exception e){}
<frame_to_close>.setVisible(false);
<frame_to_show> = new ...;
<frame_to_show>.setVisible(true);
java.awt.Window windowSplash;
2、调用prepareSplash()函数,初始化启动画面
private void prepareSplash(){
Toolkit toolkit = Toolkit.getDefaultToolkit();
windowSplash = new Window( this );
Image image = toolkit.getImage( "images" + File.separator "splash.gif" );
ImageCanvas canvas = new ImageCanvas( image );
windowSplash.add( canvas, "Center" );
Dimension scmSize = toolkit.getScreenSize();
int imgWidth = image.getWidth( this );
int imgHeight = image.getHeight( this );
windowSplash.setLocation( scmSize.width/2 - (imgWidth/2), scmSize.height/2 - (imgHeight/2) );
windowSplash.setSize( imgWidth, imgHeight );
}3、在applition的JFrame类中调用startSplash(),显示启动画面,然后初始化JFrame的各个可是化组件,初始化后台数据库等
private void startSplash(){
windowSplash.setVisible( true );
windowSplash.toFront();
}
4、在所有的初始化工作完成之后,调用stopSplash()函数,停止显示启动画面
private void stopSplash() {
windowSplash.dispose();
}
基本上,你可以拿来直接应用。