if (runCount > tabRuns.length) expandTabRunsArray();
    protected void calculateTabRects(int tabPlacement, int tabCount)    {      if (tabCount == 0)        return;      FontMetrics fm = getFontMetrics();      SwingUtilities.calculateInnerArea(tabPane, calcRect);      Insets tabAreaInsets = getTabAreaInsets(tabPlacement);      Insets insets = tabPane.getInsets();      int max = 0;      int runs = 0;      int start = getTabRunIndent(tabPlacement, 1);      if (tabPlacement == SwingConstants.TOP          || tabPlacement == SwingConstants.BOTTOM)        {          int maxHeight = calculateMaxTabHeight(tabPlacement);          calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;          max = calcRect.width + tabAreaInsets.left + insets.left;          start += tabAreaInsets.left + insets.left;          int width = 0;          int runWidth = start;          for (int i = 0; i < tabCount; i++)            {              width = calculateTabWidth(tabPlacement, i, fm);              if (runWidth + width > max)                {                  runWidth = tabAreaInsets.left + insets.left                  + getTabRunIndent(tabPlacement, ++runs);                  rects[i] = new Rectangle(runWidth,                                           insets.top + tabAreaInsets.top,                                           width, maxHeight);                  runWidth += width;                  if (runs > tabRuns.length - 1)                    expandTabRunsArray();                  tabRuns[runs] = i;                }              else                {                  rects[i] = new Rectangle(runWidth,                                           insets.top + tabAreaInsets.top,                                           width, maxHeight);                  runWidth += width;                }            }          runs++;          tabAreaRect.width = tabPane.getWidth() - insets.left - insets.right;          tabAreaRect.height = runs * maxTabHeight          - (runs - 1) * tabRunOverlay          + tabAreaInsets.top + tabAreaInsets.bottom;          contentRect.width = tabAreaRect.width;          contentRect.height = tabPane.getHeight() - insets.top          - insets.bottom - tabAreaRect.height;          contentRect.x = insets.left;          tabAreaRect.x = insets.left;          if (tabPlacement == SwingConstants.BOTTOM)            {              contentRect.y = insets.top;              tabAreaRect.y = contentRect.y + contentRect.height;            }          else            {              tabAreaRect.y = insets.top;              contentRect.y = tabAreaRect.y + tabAreaRect.height;            }        }      else        {          int maxWidth = calculateMaxTabWidth(tabPlacement);          calcRect.height -= tabAreaInsets.top + tabAreaInsets.bottom;          max = calcRect.height + tabAreaInsets.top + insets.top;          int height = 0;          start += tabAreaInsets.top + insets.top;          int runHeight = start;          int fontHeight = fm.getHeight();          for (int i = 0; i < tabCount; i++)            {              height = calculateTabHeight(tabPlacement, i, fontHeight);              if (runHeight + height > max)                {                  runHeight = tabAreaInsets.top + insets.top                  + getTabRunIndent(tabPlacement, ++runs);                  rects[i] = new Rectangle(insets.left + tabAreaInsets.left,                                           runHeight, maxWidth, height);                  runHeight += height;                  if (runs > tabRuns.length - 1)                    expandTabRunsArray();                  tabRuns[runs] = i;                }              else                {                  rects[i] = new Rectangle(insets.left + tabAreaInsets.left,                                           runHeight, maxWidth, height);                  runHeight += height;                }            }          runs++;          tabAreaRect.width = runs * maxTabWidth - (runs - 1) * tabRunOverlay          + tabAreaInsets.left + tabAreaInsets.right;          tabAreaRect.height = tabPane.getHeight() - insets.top          - insets.bottom;          tabAreaRect.y = insets.top;          contentRect.width = tabPane.getWidth() - insets.left - insets.right          - tabAreaRect.width;          contentRect.height = tabAreaRect.height;          contentRect.y = insets.top;          if (tabPlacement == SwingConstants.LEFT)            {              tabAreaRect.x = insets.left;              contentRect.x = tabAreaRect.x + tabAreaRect.width;            }          else            {              contentRect.x = insets.left;              tabAreaRect.x = contentRect.x + contentRect.width;            }        }      runCount = runs;      tabRuns[0] = 0;      normalizeTabRuns(tabPlacement, tabCount, start, max);      selectedRun = getRunForTab(tabCount, tabPane.getSelectedIndex());      if (shouldRotateTabRuns(tabPlacement))        rotateTabRuns(tabPlacement, selectedRun);      // Need to pad the runs and move them to the correct location.      for (int i = 0; i < runCount; i++)        {          int first = lastTabInRun(tabCount, getPreviousTabRun(i)) + 1;          if (first == tabCount)            first = 0;          int last = lastTabInRun(tabCount, i);          if (shouldPadTabRun(tabPlacement, i))            padTabRun(tabPlacement, first, last, max);          // Done padding, now need to move it.          if (tabPlacement == SwingConstants.TOP && i > 0)            {              for (int j = first; j <= last; j++)                rects[j].y += (runCount - i) * maxTabHeight                - (runCount - i) * tabRunOverlay;            }          if (tabPlacement == SwingConstants.BOTTOM)            {              int height = tabPane.getBounds().height - insets.bottom              - tabAreaInsets.bottom;              int adjustment;              if (i == 0)                adjustment = height - maxTabHeight;              else                adjustment = height - (runCount - i + 1) * maxTabHeight                - (runCount - i) * tabRunOverlay;              for (int j = first; j <= last; j++)                rects[j].y = adjustment;            }          if (tabPlacement == SwingConstants.LEFT && i > 0)            {              for (int j = first; j <= last; j++)                rects[j].x += (runCount - i) * maxTabWidth                - (runCount - i) * tabRunOverlay;            }          if (tabPlacement == SwingConstants.RIGHT)            {              int width = tabPane.getBounds().width - insets.right              - tabAreaInsets.right;              int adjustment;              if (i == 0)                adjustment = width - maxTabWidth;              else                adjustment = width - (runCount - i + 1) * maxTabWidth                + (runCount - i) * tabRunOverlay;              for (int j = first; j <= last; j++)                rects[j].x = adjustment;            }        }      padSelectedTab(tabPlacement, tabPane.getSelectedIndex());    }