for (int i = 0; i < column; ++i) x += columnModel.getColumn(i).getWidth();
if (column < 0) { if (! getComponentOrientation().isLeftToRight()) { cellRect.x = getWidth(); } } else if (column >= getColumnCount()) { if (getComponentOrientation().isLeftToRight()) { cellRect.x = getWidth(); } } else { TableColumnModel tcm = getColumnModel(); if (getComponentOrientation().isLeftToRight()) { for (int i = 0; i < column; i++) cellRect.x += tcm.getColumn(i).getWidth(); } else { for (int i = tcm.getColumnCount() - 1; i > column; i--) cellRect.x += tcm.getColumn(i).getWidth(); } cellRect.width = tcm.getColumn(column).getWidth(); if (! includeSpacing) {  int cMargin = tcm.getColumnMargin(); cellRect.x += cMargin / 2; cellRect.width -= cMargin; } }
  public Rectangle getCellRect(int row,                               int column,                               boolean includeSpacing)  {    int height = getRowHeight(row);    int width = columnModel.getColumn(column).getWidth();    int x_gap = columnModel.getColumnMargin();    int y_gap = rowMargin;    column = Math.max(0, Math.min(column, getColumnCount() - 1));    row = Math.max(0, Math.min(row, getRowCount() - 1));    int x = 0;    int y = (height + y_gap) * row;    for (int i = 0; i < column; ++i)      x += columnModel.getColumn(i).getWidth();    Rectangle rect = new Rectangle();    if (includeSpacing)      rect.setBounds(x, y, width, height +y_gap);    else      rect.setBounds(x, y, width - x_gap, height);    return rect;  }