哪个知道在swt中怎么在已显示的table 上再加TableItem啊

lijiang_84 2006-04-30 10:59:14
能不能在已经显示的table上再增加一些行
或这替换掉以前存在的行数据呢?
我编的这个好象不行啊~~
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;

public class SWTTest {
private Shell shell;
private Display display;
Table table;
Composite parent;
public SWTTest(Shell shell){
this.shell = shell;
FillLayout fillLayout = new FillLayout();
fillLayout.type = SWT.VERTICAL;
this.shell.setLayout(fillLayout);
parent = new Composite(shell, SWT.NO_FOCUS);
parent.setLayout(fillLayout);
createTable();
}
public void createTable(){
table = new Table(parent, SWT.MULTI |SWT.BORDER);
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn tableColumn = new TableColumn(table,SWT.LEFT);
tableColumn.setText("1");
tableColumn.setWidth(50);
TableColumn tableColumn2 = new TableColumn(table,SWT.LEFT);
tableColumn2.setText("2");
tableColumn2.setWidth(50);
Display.getCurrent().asyncExec(new Runnable(){
public void run(){
while(true){
try{
Thread.sleep(1000);
}catch(Exception e){}
TableItem item = new TableItem(table,SWT.CENTER);

item.setText(0, "1");
item.setText(1, "2");

}

}
});
}

public static void main(String[] args){
Display display = new Display();
Shell shell = new Shell(display);
new SWTTest(shell);
shell.open();
while(!shell.isDisposed()){
if(!display.readAndDispatch())
display.sleep();
}
display.dispose();
}

}
...全文
190 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sheisman 2006-05-02
  • 打赏
  • 举报
回复
加完之后,刷新以下pack();
lijiang_84 2006-05-01
  • 打赏
  • 举报
回复
HAHA ,实际上可以加的
就是有点慢
贝壳鱼 2006-05-01
  • 打赏
  • 举报
回复
从写一遍呢

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧