public virtual void setSortableModel(SortableTableModel model) { this.setModel((TableModel) model); this.headerListener.setTableModel(model); SortButtonRenderer sortButtonRenderer = new SortButtonRenderer(); TableColumnModel columnModel = this.getColumnModel(); for (int index = 0; index < columnModel.getColumnCount(); ++index) columnModel.getColumn(index).setHeaderRenderer((TableCellRenderer) sortButtonRenderer); model.sortByColumn(0, true); }
public SortableTable(SortableTableModel model) { base.\u002Ector((TableModel) model); SortableTable sortableTable = this; SortButtonRenderer renderer = new SortButtonRenderer(); TableColumnModel columnModel = this.getColumnModel(); for (int index = 0; index < columnModel.getColumnCount(); ++index) columnModel.getColumn(index).setHeaderRenderer((TableCellRenderer) renderer); JTableHeader tableHeader = this.getTableHeader(); this.headerListener = new SortableTableHeaderListener(model, renderer); ((Component) tableHeader).addMouseListener((MouseListener) this.headerListener); ((Component) tableHeader).addMouseMotionListener((MouseMotionListener) this.headerListener); model.sortByColumn(0, true); }