Program: 103183
Project: 103183
Buggy source:
protected void paintTab(Graphics g,int tabPlacement,Rectangle[] rects,int tabIndex,Rectangle iconRect,Rectangle textRect){
  Rectangle tabRect=rects[tabIndex];
  int selectedIndex=tabPane.getSelectedIndex();
  boolean isSelected=selectedIndex == tabIndex;
  boolean isOver=overTabIndex == tabIndex;
  Graphics2D g2=null;
  Shape save=null;
  boolean cropShape=false;
  int cropx=0;
  int cropy=0;
  if (g instanceof Graphics2D) {
    g2=(Graphics2D)g;
    Rectangle viewRect=tabScroller.viewport.getViewRect();
    int cropline;
    cropline=viewRect.x + viewRect.width;
    if ((tabRect.x < cropline) && (tabRect.x + tabRect.width > cropline)) {
      cropx=cropline - 1;
      cropy=tabRect.y;
      cropShape=true;
    }
    if (cropShape) {
      save=g2.getClip();
      g2.clipRect(tabRect.x,tabRect.y,tabRect.width,tabRect.height);
    }
  }
  paintTabBackground(g,tabPlacement,tabIndex,tabRect.x,tabRect.y,tabRect.width,tabRect.height,isSelected);
  paintTabBorder(g,tabPlacement,tabIndex,tabRect.x,tabRect.y,tabRect.width,tabRect.height,isSelected);
  String title=tabPane.getTitleAt(tabIndex);
  Font font=tabPane.getFont();
  FontMetrics metrics=g.getFontMetrics(font);
  Icon icon=getIconForTab(tabIndex);
  layoutLabel(tabPlacement,metrics,tabIndex,title,icon,tabRect,iconRect,textRect,isSelected);
  paintText(g,tabPlacement,font,metrics,tabIndex,title,textRect,isSelected);
  paintIcon(g,tabPlacement,tabIndex,icon,iconRect,isSelected);
  paintFocusIndicator(g,tabPlacement,rects,tabIndex,iconRect,textRect,isSelected);
  if (cropShape) {
    paintCroppedTabEdge(g,tabPlacement,tabIndex,isSelected,cropx,cropy);
    g2.setClip(save);
  }
 else   if (isOver || isSelected) {
    int dx=tabRect.x + tabRect.width - BUTTONSIZE - WIDTHDELTA;
    int dy=(tabRect.y + tabRect.height) / 2 - 3;
    if (isCloseButtonEnabled)     paintCloseIcon(g2,dx,dy,isOver);
    if (isMaxButtonEnabled)     paintMaxIcon(g2,dx,dy,isOver);
  }
}

Fixed version (ground truth):
protected void paintTab(Graphics g,int tabPlacement,Rectangle[] rects,int tabIndex,Rectangle iconRect,Rectangle textRect){
  Rectangle tabRect=rects[tabIndex];
  int selectedIndex=tabPane.getSelectedIndex();
  boolean isSelected=selectedIndex == tabIndex;
  boolean isOver=overTabIndex == tabIndex;
  Graphics2D g2=null;
  Shape save=null;
  boolean cropShape=false;
  int cropx=0;
  int cropy=0;
  if (g instanceof Graphics2D) {
    g2=(Graphics2D)g;
    Rectangle viewRect=tabScroller.viewport.getViewRect();
    int cropline;
    cropline=viewRect.x + viewRect.width;
    if ((tabRect.x < cropline) && (tabRect.x + tabRect.width > cropline)) {
      cropx=cropline - 1;
      cropy=tabRect.y;
      cropShape=true;
    }
    if (cropShape) {
      save=g2.getClip();
      g2.clipRect(tabRect.x,tabRect.y,tabRect.width,tabRect.height);
    }
  }
  paintTabBackground(g,tabPlacement,tabIndex,tabRect.x,tabRect.y,tabRect.width,tabRect.height,isSelected);
  paintTabBorder(g,tabPlacement,tabIndex,tabRect.x,tabRect.y,tabRect.width,tabRect.height,isSelected);
  String title=tabPane.getTitleAt(tabIndex);
  Font font=tabPane.getFont();
  FontMetrics metrics=g.getFontMetrics(font);
  Icon icon=getIconForTab(tabIndex);
  layoutLabel(tabPlacement,metrics,tabIndex,title,icon,tabRect,iconRect,textRect,isSelected);
  paintText(g,tabPlacement,font,metrics,tabIndex,title,textRect,isSelected);
  paintIcon(g,tabPlacement,tabIndex,icon,iconRect,isSelected);
  paintFocusIndicator(g,tabPlacement,rects,tabIndex,iconRect,textRect,isSelected);
  if (cropShape) {
    paintCroppedTabEdge(g,tabPlacement,tabIndex,isSelected,cropx,cropy);
    g2.setClip(save);
  }
 else   if (isOver || isSelected) {
    Rectangle closeRect=newCloseRect(tabRect);
    int dx=closeRect.x;
    int dy=closeRect.y;
    if (isCloseButtonEnabled)     paintCloseIcon(g2,dx,dy,isOver);
    if (isMaxButtonEnabled)     paintMaxIcon(g2,dx,dy,isOver);
  }
}