30.7 How do I display a splash screen type form, one with only client area (no border or titlebar) http://www.syncfusion.com/faq/winforms/search/621.asp
1、新建一个启动画面Window类
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 ); }
Simple Splash Screens
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=406
30.7 How do I display a splash screen type form, one with only client area (no border or titlebar)
http://www.syncfusion.com/faq/winforms/search/621.asp
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、在Application的JFrame类(主界面)中调用startSplash(),显示启动界面,然后初试化JFrame的各个可视化组件,初始化后台数据库等(如数据
库的连接)
private void startSplash()
{
windowSplash.setVisible( true );
windowSplash.toFront();
}
4、在所有的初始化工作完成之后,调用stopSplash()函数,停止显示启动画面
private void stopSplash()
{
windowSplash.dispose();
}
再说如何人为设置等待时间。
如:setIdel(1000);
t.setBounds(100, 100, 100, 100);
t.setUndecorated(true);
t.setVisible(true);
Thread.sleep(1000);
t.dispose();