現(xiàn)象:
JBuilder啟動(dòng)時(shí)有一個(gè)啟動(dòng)畫面,在Jbuilder所有的初始化工作都完成之后,啟動(dòng)畫面消失,繼而JBuilder可以開始使用。
解決方案:
該方案基于我所做過的一個(gè)項(xiàng)目。
1、新建一個(gè)啟動(dòng)畫面Window類
java.awt.Window windowSplash;
2、調(diào)用prepareSplash()函數(shù),初始化啟動(dòng)界面
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類(主界面)中調(diào)用startSplash(),顯示啟動(dòng)界面,然后初試化JFrame的各個(gè)可視化組件,初始化后臺數(shù)據(jù)庫等(如數(shù)據(jù)
庫的連接)
private void startSplash()
{
windowSplash.setVisible( true );
windowSplash.toFront();
}
4、在所有的初始化工作完成之后,調(diào)用stopSplash()函數(shù),停止顯示啟動(dòng)畫面
private void stopSplash()
{
windowSplash.dispose();
}
JBuilder啟動(dòng)時(shí)有一個(gè)啟動(dòng)畫面,在Jbuilder所有的初始化工作都完成之后,啟動(dòng)畫面消失,繼而JBuilder可以開始使用。
解決方案:
該方案基于我所做過的一個(gè)項(xiàng)目。
1、新建一個(gè)啟動(dòng)畫面Window類
java.awt.Window windowSplash;
2、調(diào)用prepareSplash()函數(shù),初始化啟動(dòng)界面
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類(主界面)中調(diào)用startSplash(),顯示啟動(dòng)界面,然后初試化JFrame的各個(gè)可視化組件,初始化后臺數(shù)據(jù)庫等(如數(shù)據(jù)
庫的連接)
private void startSplash()
{
windowSplash.setVisible( true );
windowSplash.toFront();
}
4、在所有的初始化工作完成之后,調(diào)用stopSplash()函數(shù),停止顯示啟動(dòng)畫面
private void stopSplash()
{
windowSplash.dispose();
}