我的软件在做完以后,要求在启动完成以前加载一个图片的欢迎界面。
这个功能许多软件都有,象Word, photoshop,Eclipse等,
那么应当如何加载呢?
是不是用JFrame或者JDialog实现,那么它的属性应当如何设置呢?

解决方案 »

  1.   

    C:\Program Files\Java\jdk1.5.0_06\demo\jfc\SwingSet2\SwingSet.jar
    这个JDK自带的例子就有一个你的要求的欢迎界面
      

  2.   

    /**
         * Show the spash screen while the rest of the demo loads
         */
        public void createSplashScreen() {
    splashLabel = new JLabel(createImageIcon("Splash.jpg", "Splash.accessible_description"));

    if(!isApplet()) {
        splashScreen = new JWindow(getFrame());
        splashScreen.getContentPane().add(splashLabel);
        splashScreen.pack();
        Rectangle screenRect = getFrame().getGraphicsConfiguration().getBounds();
        splashScreen.setLocation(
             screenRect.x + screenRect.width/2 - splashScreen.getSize().width/2,
     screenRect.y + screenRect.height/2 - splashScreen.getSize().height/2);

        }
      

  3.   

    然后在主Frame的构造方法里调用 createSplashScreen(); // do the following on the gui thread
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
    showSplashScreen();
        }
    });