FileDocCategorySizeDatePackage
SortingColumnModel.javaAPI DocExample761Mon Nov 09 12:45:48 GMT 1998None

SortingColumnModel

public class SortingColumnModel extends DefaultTableColumnModel

Fields Summary
Constructors Summary
Methods Summary
public voidaddColumn(javax.swing.table.TableColumn tc)

    super.addColumn(tc);
    int newIndex = sortedIndexOf(tc);
    if (newIndex != tc.getModelIndex()) {
      moveColumn(tc.getModelIndex(), newIndex);
    }
  
protected intsortedIndexOf(javax.swing.table.TableColumn tc)

    // just do a linear search for now
    int stop = getColumnCount();
    String name = tc.getHeaderValue().toString();

    for (int i = 0; i < stop; i++) {
      if (name.compareTo(getColumn(i).getHeaderValue().toString()) <= 0) {
        return i;
      }
    }
    return stop;