Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4114885

Without pack(), Swing components won't get painted correctly on Solaris 2.5.1.

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs

      The following commnet is from one of our customers :

      > SwingSet/pack problem
      > ---------------------
      > In the SwingSet example program, the initial progress window does not
      > display correctly. The contents of the window do not appear. I encountered
      > this same problem when I switched to jdk1.1.5. In my windows that called
      > setSize,validate instead of pack, the window contents did not appear. I
      > submitted this to Sun, and they dismissed it as a "user's error", however
      > in previous jdk versions there was no requirement to call pack. This
      > bug can be fixed in SwingSet by adding pack prior to the calls to setSize.
      >
      > Mary Ann Widing

      Note : This bug only shows on Solaris 2.5.1.. It's fine with Solaris 2.6.1.

      Here is a simple test for you to demostrate this bug :

      import java.awt.*;
      import java.awt.event.*;
      import java.lang.*;
      import com.sun.java.swing.*;

      public class JPackTest extends JFrame{
      JPackTest(){
      JPanel testPanel = new JPanel(new BorderLayout());
      testPanel.add(new Label("hello"),BorderLayout.CENTER);
      getContentPane().setLayout(new BorderLayout());
      getContentPane().add(testPanel,BorderLayout.CENTER);
      //pack();
      setSize(100,100);
      validate();
      }
      public static void main(String args[]){
              JPackTest mainWindow = new JPackTest();

      mainWindow.show();
      mainWindow.setVisible(true);
          }
      }

            amfowler Anne Fowler (Inactive)
            pchusunw Patience Chu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: