for (Iterator i = repaintOrder.iterator(); i.hasNext();)
for (Iterator i = repaintRoots.iterator(); i.hasNext();)
  public void paintDirtyRegions()      {    // Short cicuit if there is nothing to paint.    if (dirtyComponents.size() == 0)      return;    // Swap dirtyRegions with dirtyRegionsWork to avoid locking.    synchronized (dirtyComponents)      {        HashMap swap = dirtyComponents;        dirtyComponents = dirtyComponentsWork;        dirtyComponentsWork = swap;      }    ArrayList repaintOrder = new ArrayList(dirtyComponentsWork.size());;        // We sort the components by their size here. This way we have a good        // chance that painting the bigger components also paints the smaller        // components and we don't need to paint them twice.    repaintOrder.addAll(dirtyComponentsWork.keySet());        if (comparator == null)          comparator = new ComponentComparator();        Collections.sort(repaintOrder, comparator);        repaintUnderway = true;        for (Iterator i = repaintOrder.iterator(); i.hasNext();)      {        JComponent comp = (JComponent) i.next();        // If a component is marked completely clean in the meantime, then skip        // it.        Rectangle damaged = (Rectangle) dirtyComponentsWork.remove(comp);        if (damaged == null || damaged.isEmpty())          continue;        comp.paintImmediately(damaged);          }        repaintUnderway = false;        commitRemainingBuffers();      }