code2.htm

TableColumn column = new TableColumn(this.getTable(), SWT.LEFT);
// カラムヘッダをクリックした時の処理
column.addListener(SWT.Selection, new Listener(){

   public void handleEvent(Event event) {

      // クリックされたカラム
      TableColumn currentClm = (TableColumn) event.widget;
      // ソート対象テーブル
      Table table = currentClm.getParent();

      // ここにソート処理を実装

      // ソートされたことを意味する三角印を表示
      table.setSortColumn(currentClm);
      table.setSortDirection(SWT.UP);
   }
});

人気記事トップ10

人気記事ランキングをもっと見る