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

Setting dialog nonresizable before pack causes a ridiculous dialog size

XMLWordPrintable

    • generic, sparc
    • solaris_2.5, solaris_2.5.1, solaris_2.6

      The synopsis pretty much says it all...if I do setResizable(false) before
      pack has been called, the dialog takes up the full screen.

      This worked correctly in JDK1.1 but is broken in JDK1.1.1

      See the attached application.

      NOTE: This bug may be Motif-specific; it does not seem to occur using Tiny
      (but then Tiny isn't processing events correctly, either.)

      richard.berlin@Eng 1997-03-27
      ------------------------------------------
      One of our licensees has some examples and info to add.
      Note : these examples give different results when using JWS.
      1. is top-left and the correct size, not full screen
      2. is top-left and the correct size, regardless of setResizeable.
      3. is top-left, regardless of setResizeable.

      On JDK 1.1.4 they give the described problems.

      ------ DialogSize1.java ------

      /*
      ** On 1.1: The dialog box is set to the specified size at the expected
      ** position on the screen (near the parent window).
      ** On 1.1.1-1.1.2: The dialog box takes up the whole screen.
      ** If setResizable(false) is commented out, then it is the
      ** correct size, but it appears at the top-left corner of the
      ** screen.
      **
      ** Note:
      ** pack() calls addNotify(), so this is essentially equivalent to
      **
      ** setResizable(false);
      ** pack();
      */

      import java.awt.*;

      public class DialogSize1 extends Dialog
      {
        public static void main(String argv[])
        {
          Frame fr = new Frame();
          fr.setSize(300,200);
          fr.setVisible(true);
          new DialogSize1(fr, "Dialog Test", false).setVisible(true);
        }

        public DialogSize1(Frame parent, String title, boolean modal)
        {
          super(parent, title, modal);

          setResizable(false);
          addNotify();
          setSize(100,50);
        }
      }


      ------ DialogSize2.java ------

      /*
      ** On 1.1: The dialog box is set to the specified size at the expected
      ** position on the screen (near the parent window).
      ** On 1.1.1-1.1.2: The dialog box is set to the specified size, but it
      ** appears at the top-left corner of the screen.
      ** Same behaviour if setResizable(false) is commented out.
      */

      import java.awt.*;

      public class DialogSize2 extends Dialog
      {
        public static void main(String argv[])
        {
          Frame fr = new Frame();
          fr.setSize(300,200);
          fr.setVisible(true);
          new DialogSize2(fr, "Dialog Test", false).setVisible(true);
        }

        public DialogSize2(Frame parent, String title, boolean modal)
        {
          super(parent, title, modal);

          addNotify();
          setResizable(false);
          setSize(100,50);
        }
      }


      ------ DialogSize3.java ------

      /*
      ** On 1.1: The dialog box is set to the specified size at the expected
      ** position on the screen (near the parent window).
      ** On 1.1.1-1.1.2: The dialog box is the correct size, but comes up in
      ** unexpected positions on the screen.
      ** If 'setResizable(false)' is commented out, it appears at the
      ** top-left corner of the screen.
      */

      import java.awt.*;

      public class DialogSize3 extends Dialog
      {
        public static void main(String argv[])
        {
          Frame fr = new Frame();
          fr.setSize(300,200);
          fr.setVisible(true);
          new DialogSize3(fr, "Dialog Test", false).setVisible(true);
        }

        public DialogSize3(Frame parent, String title, boolean modal)
        {
          super(parent, title, modal);

          setResizable(false);
          setSize(100,50);
          addNotify();
        }
      }



            rkhansunw Robi Khan (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: