使用SWT eclipse在Java中编辑GridData?

时间:2012-07-18 19:31:36

标签: java swt

我得到了一个使用GridData的代码,如下所示:

public DetailView(Composite parent) {
        carModel = new Composite(parent, SWT.NONE);
        carModel.setLayoutData(new GridData(GridData.FILL_BOTH));
        carModel.setLayout(new GridLayout());
}

public void constructView() {
        carModelViewer = new TableViewer(carModelComposite, SWT.BORDER);
        CarModelProvider = new carModelContentProvider();
        carModelViewer.setContentProvider(carModelProvider);
        carModelViewer.setLabelProvider(new CarModelLabelProvider());

        Table carModel = carModelViewer.getTable();
        carModel.setHeaderVisible(true);
        carModel.setLinesVisible(true);
        carModel.setLayoutData(new GridData(GridData.FILL_BOTH));

        TableColumn carModelColumn = new TableColumn(carModel, SWT.LEFT);
        carModelColumn.setText("Model:");
        carModel.pack();
}

我想知道是否有可能在应用程序的UI中编辑单元格。我尝试阅读API并找到两种方法: 1. setCellEditor() 2. setCellModifier() 但我不确定参数。任何帮助?

1 个答案:

答案 0 :(得分:0)

GridData与单元格的内容完全无关,它只是告诉整个表格应该如何定位在父组合中。如果要更改表格的布局,请阅读Understanding layouts in SWT

如果您想让用户更改单元格的内容,请阅读Building and delivering a table editor with SWT/JFace