while (ncomponents > 0) remove(0);
for ( int index = 0; index < ncomponents; index++) { Component r = component[index];  ComponentListener[] list = r.getComponentListeners(); for (int j = 0; j < list.length; j++) r.removeComponentListener(list[j]);  r.removeNotify();  if (layoutMgr != null) layoutMgr.removeLayoutComponent(r);  r.parent = null;  if (isShowing ()) {  ContainerEvent ce = new ContainerEvent(this, ContainerEvent.COMPONENT_REMOVED, r);  getToolkit().getSystemEventQueue().postEvent(ce); } }  invalidate();  ncomponents = 0;
  public void removeAll()  {    synchronized (getTreeLock ())      {        while (ncomponents > 0)          remove(0);      }  }