如何更改TableItem的索引?

时间:2009-07-29 20:41:00

标签: java eclipse swt

在SWT表中我有很多TableItem。 我想将其中一个从索引X移动到索引Y. 有没有办法做到这一点?怎么样?

感谢。

1 个答案:

答案 0 :(得分:5)

我认为没有直接的方法可以做到这一点。但作为解决方法,请尝试以下方法。我曾经使用过类似的东西。

public void moveTableItem(Table table, int from, int to) {
    TableItem item2Move = table.getItem(from);
    TableItem newTableItem = new TableItem(table, SWT.NONE, to);
    newTableItem.setText(item2Move.getText());
    // You may want to clone the entire item here; and not just the text.

    // Dispose off, the old item.
    item2Move.dispose();

}