| |
现象: jbuilder启动时有一个启动画面,在jbuilder所有的初始化工作都完成之后,启动画面消失,继而jbuilder可以开始使用。 解决方案: 该方案基于我所做过的一个项目。 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 ); } 3、在application的jframe类(主界面)中调用startsplash(),显示启动界面,然后初试化jframe的各个可视化组件,初始化后台数据库等(如数据库的连接) private void startsplash() { windowsplash.setvisible( true ); windowsplash.tofront(); } 4、在所有的初始化工作完成之后,调用stopsplash()函数,停止显示启动画面 private void stopsplash() { windowsplash.dispose(); }
|
|