Question

In my first column of my table, the displayed value is offset from the left edge.

Example

enter image description here

Notice the offset of the date value compared to the ItemId value

TableViewerColumn col = new TableViewerColumn(this , SWT.NONE);
  col.getColumn().setWidth(125);
  col.getColumn().setText("Date Created");
  col.setLabelProvider(new ColumnLabelProvider() {
    @Override
    public String getText(Object element) {
       AplotSaveDataModel.SaveData p = (AplotSaveDataModel.SaveData) element;
      return p.getDateTime();
    }
  });

  col = new TableViewerColumn(this , SWT.NONE);
  col.getColumn().setWidth(100);
  col.getColumn().setText("ItemId");
  col.setLabelProvider(new ColumnLabelProvider() {
    @Override
    public String getText(Object element) {
       AplotSaveDataModel.SaveData p = (AplotSaveDataModel.SaveData) element;
      return p.getItemId();
    }
  });

Looking at the code above I do not see why they would be a difference?

Était-ce utile?

La solution

That's one of the very annoying SWT bugs when using windows. Here is the bug report. In windows, if the table contains an image which is not in the first column, the first column will show this "gap".

You can use a dirty fix by skipping the first column (not using it) and setting its width to zero.

As far as I remember correctly, this will introduce some minor glitches when using MacOS.


There is a very hacky work-around here as well.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top