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

Frame's pack() has problem.

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description

      JDK Version: 1.2beta4-G
      OS: Soalris 2.6
      Locale: zh, C

      Frame's pack() method sometimes make the frame just in the smallest size.
      Following is a program to reproduce it.

      ===============================CheckPack.java=============================
      import java.awt.*;
      import java.awt.event.*;
      import java.io.*;

      public class CheckPack {
         
         Choice choice1;
         Choice choice2;
         Choice choice3;
         int itemCount = 0;

         public static void main(String args[]) {
             if (args.length < 1) {
                 System.out.println("Please type: java CheckPack n");
                 System.out.println(" n should be an integer");
      return;
             }
             for (int i = 0; i < Integer.parseInt(args[0]); i ++) {
                 new CheckPack(i);
      }
         }

         public CheckPack(int k) {
             Frame f = new Frame("Check Choice");
             f.setLayout(new BorderLayout());
             choice1 = new Choice();
             choice2 = new Choice();
             choice3 = new Choice();
             f.add(choice1, BorderLayout.NORTH);
             f.add(choice3, BorderLayout.CENTER);
             f.add(choice2, BorderLayout.SOUTH);
             setData();
             f.setLocation(k * 30, k * 30);
             f.pack();
             f.show();
         }

         public void setData() {
             if (choice1 != null && itemCount < 20) {
      for (int i = 0; i < 20; i ++) {
                     choice1.add("I am Choice, yes I am : " + itemCount * itemCount);
                     choice2.add("I am the same, yes I am : "+ itemCount * itemCount);
                     choice3.add("I am the same, yes I am : "+ itemCount * itemCount);
      }
                  itemCount = 20;
             }
          }
      }

      ===============================================================================

      save this file
      javac CheckPack.java
      java CheckPack 10
      you will see this problem



      jim.hu@prc 1998-05-22

        Attachments

          Activity

            People

            Assignee:
            jdunnsunw Jeffrey Dunn (Inactive)
            Reporter:
            jhusunw Jim Hu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: