如何制作一闪而过的欢迎屏幕,比如说ms office
进入时的图片

解决方案 »

  1.   

     为 Java 桌面应用程序添加 Splash 屏幕  
      

  2.   

    http://tech.sina.com.cn/s/2006-04-19/1457909992.shtml
    使用jdk/jre 6以上的版本,挺方便的.
      

  3.   

    看来要研究一下jdk1.6的了.以前一直用低版本的.
      

  4.   

    我N年前的源码(去掉了一些):import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;public class App {
      JFrame frame;
      JWindow splash;
      public App(GraphicsConfiguration gc) {
        frame = new JFrame("app", gc);
        createSplash();
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            showSplash();
            splash.repaint();
          }
        });
        initFrame();
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            showFrame();
            hideSplash();
          }
        });
      }
      private void createSplash() {
        splash = new JWindow(frame);
        splash.getContentPane().add(new JLabel(new ImageIcon("images/splash.jpg")));
        splash.pack();
        Rectangle rec = frame.getGraphicsConfiguration().getBounds();
        splash.setLocation(rec.x + rec.width/2 - splash.getSize().width/2,
                           rec.y + rec.height/2 - splash.getSize().height/2);
      }
      private void showSplash() {
        splash.show();
      }
      private void hideSplash() {
        splash.setVisible(false);
        splash = null;
      }
      private void initFrame() {
        // some code here
      }  private void showFrame() {
        frame.pack();
        frame.setVisible(true);
        frame.repaint();
      }
      public static void main(String[] args) {
        new App(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration());
      }
    }