int runs = 1; int start = 0; int top = 0;
    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 runs = 1;      int start = 0;      int top = 0;      if (tabPlacement == SwingConstants.TOP          || tabPlacement == SwingConstants.BOTTOM)        {          int maxHeight = calculateMaxTabHeight(tabPlacement);          calcRect.width -= tabAreaInsets.left + tabAreaInsets.right;          start = tabAreaInsets.left + insets.left;          int width = 0;          int runWidth = start;          top = insets.top + tabAreaInsets.top;          for (int i = 0; i < tabCount; i++)            {              width = calculateTabWidth(tabPlacement, i, fm);              rects[i] = new Rectangle(runWidth, top, width, maxHeight);              runWidth += width;            }          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;          int height = 0;          start = tabAreaInsets.top + insets.top;          int runHeight = start;          int fontHeight = fm.getHeight();          top = insets.left + tabAreaInsets.left;          for (int i = 0; i < tabCount; i++)            {              height = calculateTabHeight(tabPlacement, i, fontHeight);              rects[i] = new Rectangle(top, runHeight, maxWidth, height);              runHeight += height;            }          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;      if (runCount > tabRuns.length)        expandTabRunsArray();      padSelectedTab(tabPlacement, tabPane.getSelectedIndex());    }