java - org.eclipse.swt.widgets.Table - 添加项目

标签 java eclipse eclipse-plugin

我想向电子邮件列和删除列添加一个项目。你如何做到这一点? 我一直在寻找添加方法或其他东西,但我什么也没找到。 我在设置一些字符串后尝试了 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/

相关文章:

java - 为什么我的 Eclipse 插件显示在 Eclipse RCP 版本中,但没有显示在 Java 和 Java EE 等其他版本中?

java - Eclipse 包资源管理器中的不同 IResource

java - 如何让Java中的扫描仪不关心标点符号

java - 将 mojo 添加到另一个 Maven 插件定义的自定义生命周期

Java 日志管理器通过在运行 Java 代码时传递属性来覆盖默认值

android - 将Gradle Nature添加到Eclipse上的现有android项目

eclipse - 在不打开的情况下升级 Eclipse

java - 构造 EncryptedPrivateKeyInfo 时出现异常

java - 无法与 Eclipse/subversive 共享某些项目

eclipse - 如何强制为相同的输入打开第二个编辑器?