我想向电子邮件列和删除列添加一个项目。你如何做到这一点? 我一直在寻找添加方法或其他东西,但我什么也没找到。 我在设置一些字符串后尝试了 setData 和重绘,但这不起作用。
这是我到目前为止的代码:
Table emailTable = new Table(composite_2, SWT.BORDER | SWT.FULL_SELECTION);
FormData fd_table = new FormData();
fd_table.bottom = new FormAttachment(emailText, -3);
fd_table.top = new FormAttachment(0, 10);
fd_table.right = new FormAttachment(emailLabel, 481);
fd_table.left = new FormAttachment(emailLabel, 0, SWT.LEFT);
Table emailTable.setLayoutData(fd_table);
Table emailTable.setHeaderVisible(true);
Table emailTable.setLinesVisible(true);
TableColumn emailColumn = new TableColumn(emailTable, SWT.NONE);
TableColumn emailColumn.setWidth(377);
TableColumn emailColumn.setText("Email");
TableColumn removeColumn = new TableColumn(emailTable, SWT.NONE);
TableColumn removeColumn.setWidth(100);
TableColumn removeColumn.setText("Remove");
最佳答案
您需要在构造函数 emailTable
中创建带有第一个参数的 TableItem
,并按照 http://www.vogella.com/tutorials/SWT/article.html#swt_table 中所述设置其文本。 :
TableItem item = new TableItem(emailTable, SWT.NONE);
item.setText (0, "test@example.org");
关于java - org.eclipse.swt.widgets.Table - 添加项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27368069/