Swing有这个功能相关的api的,忘了^-^

解决方案 »

  1.   

    我觉得一般是用JDialog的(辅助线程Thread.sleep(要显示的秒数))
      

  2.   

    在Frame上插入一个panel,在pannel上插入图片!
      

  3.   

    觉得还是使用Frame比较方便实现。可以把放置照片的Frame的标题栏去掉。这样就没有什么不雅的了。
      

  4.   

    将代码改为(其中showYourFatherFrame()是你的父窗体的显示方法):      createSplashScreen();      // do the following on the gui thread
          SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                showSplashScreen();
             }
          });      initialize();      // Show the frame and take down the splash screen. Note that
          // we again must do this on the GUI thread using invokeLater.
          SwingUtilities.invokeLater(new Runnable() {
             public void run() {
                showYourFatherFrame();
                hideSplash();
             }
          });
    附showSplashScreen() & showFrame() & hideSplash()(fatherFrame代表你的父容器或父窗体)   private JWindow splashScreen = null;
       private JLabel splashLabel = null;   /**
        * create the splash screen
        */
       public void createSplashScreen() {
          splashLabel = new JLabel(new ImageIcon("imagepath"));      splashScreen = new JWindow(fatherFrame);
          splashScreen.getContentPane().add(splashLabel);
          splashScreen.pack();
          Rectangle screenRect = father.getGraphicsConfiguration().getBounds();
          splashScreen.setLocation(
                screenRect.x + screenRect.width/2 - splashScreen.getSize().width/2,
                screenRect.y + screenRect.height/2 - splashScreen.getSize().height/2);
       }   /**
        * show the splash screen
        */
       public void showSplashScreen() {
          splashScreen.show();
       }   /**
        * pop down the spash screen
        */
       public void hideSplash() {
          splashScreen.setVisible(false);
          splashScreen = null;
          splashLabel = null;
       }
      

  5.   

    showFrame()是笔误,应为showYourFatherFrame(),这个就不用写了吧!
      

  6.   

    厉害厉害,谢谢 森林之洋, 请教一下, 你程序中的pack()函数是用来干什么的??
    看API也不是很明白!
    每次使用了 感觉和没使用 没区别啊
      

  7.   

    java.awt.Window.pack()
    public void pack()
        Causes this Window to be sized to fit the preferred size and layouts of its
        subcomponents. If the window and/or its owner are not yet displayable, both
        are made displayable before calculating the preferred size. The Window will be
        validated after the preferredSize is calculated. 就是这个意思啊!翻译过来就是使窗口的大小适合于优选尺寸,并为它的子组件布局。如果这个窗口和/或它的拥有者是不可显示的,那么上面两者在计算优选尺寸时被设置成为不可见。窗口将在优选尺寸的计算完成后有效。如果不使用pack(),并且在使用pack()处加入代码:
             splashScreen.setSize(new Dimension(100, 100));
    那么再看看结果,发现它并不是优选尺寸,也就是说,这样可能放不下整张图片;但如果在该语句后跟pack(),则这个Window就不会使用它的尺寸,而是优选尺寸。
      

  8.   

    一个是Window类的应用
    二是线程的应用
    ok~~~~~
      

  9.   

    谢谢森林海洋的指点,pack()函数的使用让我明白了很多!
    但是不是会产生这样的后果,如果使用pack()函数的话,
    window会自动调整各个组件的大小,即使我们写了setSize(new Dimension(...))函数,
    在已有pack()函数的情况下,window也只会自动设置优先尺寸,那样的话,是不是setSize()
    函数将没有意义了??
      

  10.   

    这就由你的程序要求决定了,如果你需要的是一个PreferredSize的Window(包括其子组件)实例,那么你就不用伤脑筋去计算它的尺寸了,pack(),就一切搞定;反之,如果你不希望你的Window使用选选尺寸的话,那么setSize()的功能就可以显现出来了,举一个简单的例子,就是你不希望你的Window的某个直接子组件((J)Button)等并不使用它的优选尺寸,那么这个pack()在这里就不可以使用了,而这时,整个窗口的大小就由setSize()来确定了。