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

SwingUtilities.convertPoint(To|From)Screen() methods throw unspecified exception

XMLWordPrintable

    • beta
    • generic, sparc
    • generic, solaris_2.6



      Name: aaR10142 Date: 06/28/2000


      SwingUtilities.convertPointToScreen() and
      SwingUtilities.convertPointFromScreen() methods throw unspecified
      IllegalComponentStateException
      The javadoc says nothing about it.

      The javadoc says:"
      public static void convertPointFromScreen(Point p,
                                                Component c)

            Convert a point from a screen coordinates to a
            component's coordinate system
            Parameters:
                  p - a Point object (converted to the new
                  coordinate system)
                  c - a Component object


      "

      All works correctly in jdk1.3
      See example

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

      public class Test {

          public static void main(String argv[]) {
              JFrame c = new JFrame();
              Point pt=new Point(0,0);

              SwingUtilities.convertPointToScreen(pt, c);
              System.out.println("result:"+ pt);

              SwingUtilities.convertPointFromScreen(pt, c);
              System.out.println("result:"+ pt);

           }

      }

      ------------------------- jdk1.4 output ----------------
      Exception in thread "main" java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
              at java.awt.Component.getLocationOnScreen_NoTreeLock(Component.java:1316)
              at java.awt.Component.getLocationOnScreen(Component.java:1290)
              at javax.swing.SwingUtilities.convertPointToScreen(SwingUtilities.java:255)
              at Test.main(Test.java:10)
      ------------------------- jdk1.3 output ----------------
      result:java.awt.Point[x=0,y=0]
      result:java.awt.Point[x=0,y=0]

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

            svioletsunw Scott Violet (Inactive)
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: