gfx.translate(bounds.x, bounds.y); gfx.setClip(0, 0, bounds.width, bounds.height); comp.setSize(bounds.width, bounds.height); comp.setLocation(0,0); comp.paint(gfx); gfx.translate(-bounds.x, -bounds.y); gfx.setClip(oldClip);
rendererPane.paintComponent(gfx, comp, header, bounds.x, bounds.y, bounds.width, bounds.height);
  public void paint(Graphics gfx, JComponent c)  {    TableColumnModel cmod = header.getColumnModel();    int ncols = cmod.getColumnCount();    if (ncols == 0)      return;        Rectangle clip = gfx.getClipBounds();    TableCellRenderer defaultRend = header.getDefaultRenderer();    for (int i = 0; i < ncols; ++i)      {        Rectangle bounds = header.getHeaderRect(i);        if (bounds.intersects(clip))          {            Rectangle oldClip = gfx.getClipBounds();            TableColumn col = cmod.getColumn(i);            TableCellRenderer rend = col.getHeaderRenderer();            if (rend == null)              rend = defaultRend;            Object val = col.getHeaderValue();            Component comp = rend.getTableCellRendererComponent(header.getTable(),                                                                val,                                                                false, // isSelected                                                                false, // isFocused                                                                -1, i);            comp.setFont(header.getFont());            comp.setBackground(header.getBackground());            comp.setForeground(header.getForeground());            if (comp instanceof JComponent)              ((JComponent)comp).setBorder(cellBorder);            gfx.translate(bounds.x, bounds.y);            gfx.setClip(0, 0, bounds.width, bounds.height);            comp.setSize(bounds.width, bounds.height);            comp.setLocation(0,0);            comp.paint(gfx);            gfx.translate(-bounds.x, -bounds.y);            gfx.setClip(oldClip);          }      }  }