y -= (maxTabHeight - tabRunOverlay);
y -= maxTabHeight - tabRunOverlay;
    protected void calculateTabRects(int tabPlacement, int tabCount)    {      Insets insets = tabPane.getInsets();      Insets tabAreaInsets = getTabAreaInsets(tabPlacement);      Dimension size = tabPane.getSize();            // The coordinates of the upper left corner of the tab area.      int x;      int y;      // The location at which the runs must be broken.      int breakAt;      // Calculate the bounds for the tab area.      switch (tabPlacement)      {        case LEFT:          maxTabWidth = calculateMaxTabWidth(tabPlacement);          x = insets.left + tabAreaInsets.left;          y = insets.top + tabAreaInsets.top;          breakAt = size.height - (insets.bottom + tabAreaInsets.bottom);          break;        case RIGHT:          maxTabWidth = calculateMaxTabWidth(tabPlacement);          x = size.width - (insets.right + tabAreaInsets.right) - maxTabWidth;          y = insets.top + tabAreaInsets.top;          breakAt = size.height - (insets.bottom + tabAreaInsets.bottom);          break;        case BOTTOM:          maxTabHeight = calculateMaxTabHeight(tabPlacement);          x = insets.left + tabAreaInsets.left;          y = size.height - (insets.bottom + tabAreaInsets.bottom)              - maxTabHeight;          breakAt = size.width - (insets.right + tabAreaInsets.right);          break;        case TOP:        default:          maxTabHeight = calculateMaxTabHeight(tabPlacement);          x = insets.left + tabAreaInsets.left;          y = insets.top + tabAreaInsets.top;          breakAt = size.width - (insets.right + tabAreaInsets.right);          break;      }      if (tabCount == 0)        return;      FontMetrics fm = getFontMetrics();      runCount = 0;      selectedRun = -1;      int selectedIndex = tabPane.getSelectedIndex();      Rectangle rect;      // Go through all the tabs and build the tab runs.      if (tabPlacement == SwingConstants.TOP          || tabPlacement == SwingConstants.BOTTOM)        {          for (int i = 0; i < tabCount; i++)            {              rect = rects[i];              if (i > 0)                {                  rect.x = rects[i - 1].x + rects[i - 1].width;                }              else                {                  tabRuns[0] = 0;                  runCount = 1;                  maxTabWidth = 0;                  rect.x = x;            }              rect.width = calculateTabWidth(tabPlacement, i, fm);              maxTabWidth = Math.max(maxTabWidth, rect.width);              if (rect.x != 2 + insets.left && rect.x + rect.width > breakAt)            {                  if (runCount > tabRuns.length - 1)                    expandTabRunsArray();                  tabRuns[runCount] = i;                  runCount++;                  rect.x = x;            }              rect.y = y;              rect.height = maxTabHeight;              if (i == selectedIndex)                selectedRun = runCount - 1;                            }        }      else        {          for (int i = 0; i < tabCount; i++)            {              rect = rects[i];              if (i > 0)                {                  rect.y = rects[i - 1].y + rects[i - 1].height;                }              else                {                  tabRuns[0] = 0;                  runCount = 1;                  maxTabHeight = 0;                  rect.y = y;            }              rect.height = calculateTabHeight(tabPlacement, i,                                               fm.getHeight());              maxTabHeight = Math.max(maxTabHeight, rect.height);              if (rect.y != 2 + insets.top && rect.y + rect.height > breakAt)            {                  if (runCount > tabRuns.length - 1)                    expandTabRunsArray();                  tabRuns[runCount] = i;                  runCount++;                  rect.y = y;            }              rect.x = x;              rect.width = maxTabWidth;              if (i == selectedIndex)                selectedRun = runCount - 1;            }        }      if (runCount > 1)        {          int start;          if  (tabPlacement == SwingConstants.TOP              || tabPlacement == SwingConstants.BOTTOM)            start = y;          else            start = x;          normalizeTabRuns(tabPlacement, tabCount, start, breakAt);          selectedRun = getRunForTab(tabCount, selectedIndex);      if (shouldRotateTabRuns(tabPlacement))            {        rotateTabRuns(tabPlacement, selectedRun);            }        }      // Pad the runs.      int tabRunOverlay = getTabRunOverlay(tabPlacement);      for (int i = runCount - 1; i >= 0; --i)        {          int start = tabRuns[i];          int nextIndex;          if (i == runCount - 1)            nextIndex = 0;          else            nextIndex = i + 1;          int next = tabRuns[nextIndex];          int end = (next != 0 ? next - 1 : tabCount - 1);          if (tabPlacement == SwingConstants.TOP              || tabPlacement == SwingConstants.BOTTOM)        {              for (int j = start; j <= end; ++j)            {                  rect = rects[j];                  rect.y = y;                  rect.x += getTabRunIndent(tabPlacement, i);            }              if (shouldPadTabRun(tabPlacement, i))            {                  padTabRun(tabPlacement, start, end, breakAt);                }              if (tabPlacement == BOTTOM)                y -= (maxTabHeight - tabRunOverlay);              else                y += (maxTabHeight - tabRunOverlay);            }          else            {              for (int j = start; j <= end; ++j)                {                  rect = rects[j];                  rect.x = x;                  rect.y += getTabRunIndent(tabPlacement, i);            }              if (shouldPadTabRun(tabPlacement, i))            {                  padTabRun(tabPlacement, start, end, breakAt);                }              if (tabPlacement == RIGHT)                x -= (maxTabWidth - tabRunOverlay);              else                x += (maxTabWidth - tabRunOverlay);            }        }      padSelectedTab(tabPlacement, selectedIndex);    }