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

setLocationRelativeTo() position dialog at (0,0) if Frame is iconified

XMLWordPrintable

    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.5.0_06"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      setLocationRelativeTo() positions a dialog at (0,0) if its Frame parent is iconified.

      jdk 1.4.2_08 positions the dialog correctly
      jdk 1.5.0_06 positions it at (0,0)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      test class writes to System.out:
      java.awt.Point[x=150,y=150]
      ACTUAL -
      test class writes to System.out:
      java.awt.Point[x=0,y=0]

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Dialog;
      import java.awt.Frame;

      public class TestSetLocationRelativeTo {

        public static void main(String[] args) {
          Frame f = new Frame("test");
          f.setBounds(100, 100, 200, 200);
          f.setVisible(true);
          f.setExtendedState(Frame.ICONIFIED);
          Dialog dlg = new Dialog(f);
          dlg.setSize(100, 100);
          dlg.setLocationRelativeTo(f);
          dlg.setVisible(true);
          // results:
          // 1.4.2_08: java.awt.Point[x=150,y=150]
          // 1.5.0_06: java.awt.Point[x=0,y=0]
          System.out.println(dlg.getLocation());
        }
      }

      ---------- END SOURCE ----------

            yan Yuri Nesterenko
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: