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

Container.findComponentAt() behavior does not meet the doc

    XMLWordPrintable

    Details

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

      Description



      Name: aaC67449 Date: 10/22/99


      Container.findComponentAt() behavior does not meet the doc.

      It returns null for visible container (isVisible()==true), but the javadoc says
      that it should return correct value.
      see javadoc:"
      public Component findComponentAt(int x,
                                       int y)

            Locates the visible child component that contains the specified position.
                       ^^^^^^^^^^^^^^
            The top-most child component is returned in the case where there is
            overlap in the components. If the containing child component is a
            Container, this method will continue searching for the deepest nested
            child component. Components which are not visible are ignored during the
            search.

            The findComponentAt method is different from getComponentAt in that
            getComponentAt only searches the Container's immediate children; if the
            containing component is a Container, findComponentAt will search that
            child to find a nested component.
            Parameters:
                  x - the x coordinate
                  y - the y coordinate
            Returns:
                  null if the component does not contain the position. If there is no
                  child component at the requested point and the point is within the
                  bounds of the container the container itself is returned.
            Since:
                  JDK1.2
            See Also:
                  Component.contains(int, int), getComponentAt


      "
      The javadoc or method behavior should be updated.

      See example:
      ------------------------- example ----------------
      import java.awt.Panel;

      public class Test{

          public static void main(String argv[]) {

               Panel c = new Panel();
               c.setSize(100, 100);
               c.setVisible(true);
               if (c.findComponentAt(1, 1) == c) { // verify setting
                   System.out.println("Passed");
               } else {
                   System.out.println("Failed. The method returns "
                           + c.findComponentAt(1, 1));
               }

          }

      }
      -------------------- output -------------------
      Failed. The method returns null

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

        Attachments

          Activity

            People

            Assignee:
            ehawkessunw Eric Hawkes (Inactive)
            Reporter:
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: