Strange alignment and layout in tableviewer with image

I am using a TableViewer with two columns. The first should contain text, and the second - an image depending on the state of the object. A label provider is a custom provider that extends LabelProvider and implements ITableLayoutProvider .

When the image is not displayed, the layout is correct, and the text in the first column is aligned to the left. correct

But when at least one image is displayed, the text in the first column is aligned somewhere between the right and center - it looks ugly.

incorrect

The layout is pretty simple:

 availableDevicesList = new TableViewer(this, SWT.SINGLE | SWT.BORDER | SWT.FULL_SELECTION); availableDevicesList.setContentProvider(new ArrayContentProvider()); Table table = availableDevicesList.getTable(); TableLayout tableLayout = new TableLayout(); table.setLayout(tableLayout); table.setLinesVisible(true); tableLayout.addColumnData(new ColumnWeightData(3)); new TableColumn(table, SWT.LEFT); tableLayout.addColumnData(new ColumnWeightData(1)); new TableColumn(table, SWT.RIGHT); 

What causes this problem?

+6
source share
1 answer

This is a bug in the Windows API, see the SWT error report . It affects only the first column in the table, so the official workaround is to โ€œskipโ€ the first column and set it to zero size (see the last comment on the error report), but Mac OS X cannot have a size in the table table, therefore you will see the first column of size 1 or something like this ..

Yes, I hate this error in the Win API too ..

+2
source

Source: https://habr.com/ru/post/890673/


All Articles