Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 设置CheckboxTableViewer的标题_Java_Jface - Fatal编程技术网

Java 设置CheckboxTableViewer的标题

Java 设置CheckboxTableViewer的标题,java,jface,Java,Jface,CheckboxTableViewer允许创建单个检查表 但是,由于列本身不是由TableColumn创建的,因此如何放置此类列的标题呢 tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.SINGLE| SWT.BORDER | SWT.FULL_SELECTION); tableViewer.add(checkListNames.get(0)); tableViewer.add(checkListNa

CheckboxTableViewer允许创建单个检查表

但是,由于列本身不是由TableColumn创建的,因此如何放置此类列的标题呢

    tableViewer = CheckboxTableViewer.newCheckList(parent, SWT.SINGLE| SWT.BORDER | SWT.FULL_SELECTION);

    tableViewer.add(checkListNames.get(0));
    tableViewer.add(checkListNames.get(1));
    tableViewer.add(checkListNames.get(2));
    tableViewer.add(checkListNames.get(3));
    tableViewer.add(checkListNames.get(4));
    tableViewer.add(checkListNames.get(5));

    final Table table = tableViewer.getTable();

    table.setLayoutData(new GridData(GridData.FILL_BOTH));

    System.out.println(table.getColumnCount()); // this returns a zero

    table.setHeaderVisible(true);
    table.setLinesVisible(true);

您需要使用
TableLayout
TableViewerColumn
来定义列,以便设置标题文本

最低要求是:

TableLayout layout = new TableLayout();

TableViewerColumn col = new TableViewerColumn(tableViewer, SWT.LEAD);

col.getColumn().setText("Text");

layout.addColumnData(new ColumnWeightData(100));

table.setLayout(layout);

然后如何创建检查列?CheckboxTableViewer允许直接创建。检查是第一列的一部分。此代码适用于CheckboxTableViewer。将代码放在
setheadervible
callWell的前面。它工作正常,但我仍然有一个滚动条。