Java SWT:在写入之前清除表中的所有项目 [英] Java SWT: Clear all items in a table before writing
本文介绍了Java SWT:在写入之前清除表中的所有项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在写入所有行之前清除表格?每次点击这段代码,数据都会完全不同:
graphicsMemoryTable.setRedraw(false);整数计数 = 0;for(int i=0; i
作为参考,调用 removeAll()
对我有用,调用 clearAll 没有
解决方案
removeAll()
Table
方法将删除表格中的所有元素.这是javadoc;
public void removeAll()
<块引用>
从接收器中移除所有项目.
How do I clear a table before writing all the rows? The data will be completely different every time I hit this code:
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);
EDIT:
For reference, calling removeAll()
worked for me, calling clearAll did not
解决方案
removeAll()
method of Table
will remove all elements in the table. Here is the javadoc;
public void removeAll()
Removes all of the items from the receiver.
这篇关于Java SWT:在写入之前清除表中的所有项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文