コード例 #1
0
 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);
 }
コード例 #2
0
 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);
 }