getToolkit().getSystemEventQueue().postEvent(ce);
ContainerListener[] listeners = getContainerListeners(); for (int i = 0; i < listeners.length; i++) listeners[i].componentAdded(ce);
  protected void addImpl(Component comp, Object constraints, int index)  {    synchronized (getTreeLock ())      {        if (index > ncomponents            || (index < 0 && index != -1)            || comp instanceof Window            || (comp instanceof Container                && ((Container) comp).isAncestorOf(this)))          throw new IllegalArgumentException();        // Reparent component, and make sure component is instantiated if        // we are.        if (comp.parent != null)          comp.parent.remove(comp);        comp.parent = this;        if (peer != null)          {	    // Notify the component that it has a new parent.	    comp.addNotify();            if (comp.isLightweight ())	      {		enableEvents (comp.eventMask);		if (!isLightweight ())		  enableEvents (AWTEvent.PAINT_EVENT_MASK);	      }          }        // Invalidate the layout of the added component and its ancestors.        comp.invalidate();        if (component == null)          component = new Component[4]; // FIXME, better initial size?        // This isn't the most efficient implementation.  We could do less        // copying when growing the array.  It probably doesn't matter.        if (ncomponents >= component.length)          {            int nl = component.length * 2;            Component[] c = new Component[nl];            System.arraycopy(component, 0, c, 0, ncomponents);            component = c;          }          if (index == -1)          component[ncomponents++] = comp;        else          {            System.arraycopy(component, index, component, index + 1,                             ncomponents - index);            component[index] = comp;            ++ncomponents;          }        // Notify the layout manager.        if (layoutMgr != null)          {            if (layoutMgr instanceof LayoutManager2)              {                LayoutManager2 lm2 = (LayoutManager2) layoutMgr;                lm2.addLayoutComponent(comp, constraints);              }            else if (constraints instanceof String)              layoutMgr.addLayoutComponent((String) constraints, comp);            else              layoutMgr.addLayoutComponent(null, comp);          }        if (isShowing ())          {            // Post event to notify of adding the component.        ContainerEvent ce = new ContainerEvent(this,                                               ContainerEvent.COMPONENT_ADDED,                                               comp);        getToolkit().getSystemEventQueue().postEvent(ce);            // Repaint this container.            repaint();      }  }  }