if (getColumnCount() < 2) return;  int x0 = 0;  int idx0 = event.getFirstIndex(); int idxn = event.getLastIndex(); int i;
int idx0 = Math.max(0, Math.min(getColumnCount() - 1, event.getFirstIndex())); int idxn = Math.max(0, Math.min(getColumnCount() - 1, event.getLastIndex()));
  public void columnSelectionChanged (ListSelectionEvent event)  {    // Does not make sense for the table with the single column.    if (getColumnCount() < 2)      return;        int x0 = 0;        int idx0 = event.getFirstIndex();    int idxn = event.getLastIndex();    int i;    for (i = 0; i < idx0; i++)      x0 += columnModel.getColumn(i).getWidth();        int xn = x0;        for (i = idx0; i <= idxn; i++)      xn += columnModel.getColumn(i).getWidth();        repaint(x0, 0, xn-x0, getHeight());  }