int numToCopy = Math.min(tabCount, rects.length); Rectangle[] tmp = new Rectangle[tabCount]; System.arraycopy(rects, 0, tmp, 0, numToCopy); rects = tmp;
Rectangle[] old = rects; rects = new Rectangle[tabCount]; System.arraycopy(old, 0, rects, 0, old.length); for (int i = old.length; i < rects.length; i++) rects[i] = new Rectangle();
  protected void assureRectsCreated(int tabCount)  {    if (rects == null)      rects = new Rectangle[tabCount];    if (tabCount == rects.length)      return;    else      {        int numToCopy = Math.min(tabCount, rects.length);        Rectangle[] tmp = new Rectangle[tabCount];        System.arraycopy(rects, 0, tmp, 0, numToCopy);        rects = tmp;      }  }