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

WM_Active does not set focus correctly for LW components

XMLWordPrintable

    • generic
    • generic


      ingrid.yao@Eng 1997-07-29

      Problem reported by Oracle:

      WM_ACTIVATE processing tries to set the focus to the Component that had the
      focus last time the window was activated. WWindowPeer.getFocusPeer() tries to
      cast a Component's peer to WComponentPeer, which causes a ClassCastException
      for LW Components. The method needs to return the HW ancestor of the LW
      Component:

      Proposed fix:

          WComponentPeer getFocusPeer() {
              Component c = ((Window)target).getFocusOwner();
              while (c != null) {
                  ComponentPeer peer = c.getPeer();
                  if (peer != null && peer instanceof WComponentPeer) {
                      return (WComponentPeer) peer;
                  } else {
                      // peerless sub-component, try parent.
                      c = c.getParent();
                  }
              }
              return null; // no child has focus
          }

            Unassigned Unassigned
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: