如何更改TableItem的索引?

Mar*_*ato 4 java eclipse swt

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

谢谢.

Ano*_*oop 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();

}
Run Code Online (Sandbox Code Playgroud)