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

SwingUtilities.convertPoint(To|From)Screen() methods return incorrect value

    • beta
    • sparc
    • solaris_2.6



      Name: aaR10142 Date: 09/08/2000


      SwingUtilities.convertPoint(To|From)Screen() methods return incorrect value for
      invisible frames.

      These methods have used getLocation() to determine location for the
      invisible frame in jdk1.3,
      but they use (0,0) point in this case in jdk1.4.

      The old behavior looks more resonable and should be kept for compatability.

      See example.
      ------------------------- example ----------------
      import javax.swing.*;
      import java.awt.Point;

      public class Test {
          public static void main (String[] args) {
              JFrame f = new JFrame();
              f.setBounds(100,100,100,100);
              Point p = new Point(0, 0);
              SwingUtilities.convertPointToScreen(p, f);
              Point result = new Point (100, 100);
              if (!p.equals(result)) {
                  System.out.println("The method returns incorect point "+ p + "\n"
                          + "Should be " + result);
      } else {
                  System.out.println("Ok");
      }
          }
      }


      ------------------------- jdk1.4 output ----------------
      The method returns incorect point java.awt.Point[x=0,y=0]
      Should be java.awt.Point[x=100,y=100]
      ------------------------- jdk1.3 output ----------------
      Ok


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

            apikalev Andrey Pikalev
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: