如何通过单击SWT中的标题对表列进行排序?

时间:2013-12-18 19:55:14

标签: java sorting swt

我有一个SWT表,我需要为它添加排序功能...大多数列包含数值,但有些确实包含字母和日期。以下是创建表格和添加列的方式:

  protected void createTable ( Composite panel, String colnames[], Rectangle location )
  {
    TableColumn column;
    boolean checkflag = scalefactor > 0;
    int buttonwidth, properties = SWT.BORDER|SWT.FULL_SELECTION;
    if (checkflag) properties |= SWT.CHECK;
    if (colwidth == 0) colwidth = 80;
    dataTable = new Table(panel,properties);
    dataTable.setLinesVisible(true);
    dataTable.setHeaderVisible(true);
    if (checkflag)
    {
        Button button = new Button(dataTable,SWT.CHECK);
        button.pack();
        buttonwidth = button.getSize().x+4;
        button.dispose();
        column = new TableColumn(dataTable,SWT.CENTER);
        column.setWidth(buttonwidth);
        column.setResizable(true);
    }
    for ( int n = 0; n < colnames.length; n++ )
    {
      column = new TableColumn(dataTable,SWT.CENTER);
      column.setWidth(colwidth);
      column.setText(colnames[n]);
    }

我只需单击标题即可对每个创建的列进行排序。有可能吗?

0 个答案:

没有答案