Container parent = getParent ();
Container parent = (this instanceof Container) ? (Container) this : getParent();
  public void requestFocus ()  {    if (isDisplayable ()	&& isShowing ()	&& isFocusable ())      {        synchronized (getTreeLock ())          {            // Find this Component's top-level ancestor.            Container parent = getParent ();            while (parent != null                   && !(parent instanceof Window))              parent = parent.getParent ();            Window toplevel = (Window) parent;            if (toplevel.isFocusableWindow ())              {                if (peer != null && !isLightweight())                  // This call will cause a FOCUS_GAINED event to be                  // posted to the system event queue if the native                  // windowing system grants the focus request.                  peer.requestFocus ();                else                  {                    // Either our peer hasn't been created yet or we're a                    // lightweight component.  In either case we want to                    // post a FOCUS_GAINED event.                    EventQueue eq = Toolkit.getDefaultToolkit ().getSystemEventQueue ();                    synchronized (eq)                      {                        KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager ();                        Component currentFocusOwner = manager.getGlobalPermanentFocusOwner ();                        if (currentFocusOwner != null)                          {                            eq.postEvent (new FocusEvent(currentFocusOwner, FocusEvent.FOCUS_LOST,                                                         false, this));                            eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false,                                                         currentFocusOwner));                          }                        else                          eq.postEvent (new FocusEvent(this, FocusEvent.FOCUS_GAINED, false));                      }                  }              }            else              pendingFocusRequest = new FocusEvent(this, FocusEvent.FOCUS_GAINED);          }      }	}