1、新建一个启动画面Window类
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.width2 - (imgWidth2), scmSize.height2 - (imgHeight2) );
- windowSplash.setSize( imgWidth, imgHeight );
- }
3、在Application的JFrame类(主界面)中调用startSplash(),显示启动界面,然后初试
化JFrame的各个可视化组件,初始化后台数据库等(如数据库的连接)
- private void startSplash()
- {
- windowSplash.setVisible( true );
- windowSplash.toFront();
- }
4、在所有的初始化工作完成之后,调用stopSplash()函数,停止显示启动画面
- private void stopSplash() {
- windowSplash.dispose();
- }
posted on 2006-05-18 13:11
崛起的程序员 阅读(271)
评论(0) 编辑 收藏