Java SWT:写入前清除 table 中的所有项目

Java SWT: Clear all items in a table before writing

如何在写入所有行之前清除 table?每次敲这段代码,数据都会完全不同:

graphicsMemoryTable.setRedraw(false);
int count = 0;
for(int i=0; i<graphicsMemory.size() && count<1000; i+=8,count++)
{
    TableItem item = new TableItem(graphicsMemoryTable, SWT.NONE);
    item.setText(graphicsMemory.get(i).toString());
    item.setText(1,graphicsMemory.get(i+1).toString());
    item.setText(2,graphicsMemory.get(i+2).toString());
    item.setText(3,graphicsMemory.get(i+3).toString());
    item.setText(4,graphicsMemory.get(i+4).toString());
    item.setText(5,graphicsMemory.get(i+5).toString());
    item.setText(6,graphicsMemory.get(i+6).toString());
    item.setText(7,graphicsMemory.get(i+7).toString());
}
graphicsMemoryTable.setRedraw(true);

编辑: 作为参考,调用 removeAll() 对我有用,调用 clearAll 没有

removeAll() Table 方法将删除 table 中的所有元素。这是 javadoc;

public void removeAll()

Removes all of the items from the receiver.

您可以使用table.clearAll();

Clears all the items in the receiver. The text, icon and other attributes of the items are set to their default values. If the table was created with the SWT.VIRTUAL style, these attributes are requested again as needed.