Community
Participate
Working Groups
Created attachment 282400 [details] Image of NOK result How to reproduce: - Have a table with multiple columns - Create a table item - Add a short text to the first cell of the table item - add a image with significant width to any column but the first - invoke pack() on any column Observed result: - [1] [NOK] The cells of the first column is displayed with an empty space on the left followed by the short text. The width of the empty space is similar to the width of the image that was added to the second column - [2] [OK] The cells of the second column display the added image Expected result - [1] The first cell should only contain the added text. Tested NOK on windows 10 with SWT lib 4.12, 4.13, 4.14 , 4.15 and swt-I20200409-0200 Tested OK on linux 64 MINT with SWT lib 4.15 I did no other tests. Minimal code example: // START OF CODE import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; public class SwtImageInTableTest { public static void main(String[] args) { Display display = new Display (); Shell shell = new Shell (display); shell.setLayout(new GridLayout()); Table table = new Table (shell, SWT.NONE); table.setLinesVisible(true); table.setHeaderVisible(true); TableColumn columnWithText = new TableColumn (table, SWT.NONE); columnWithText.setText ("Text"); TableColumn columnWithImage = new TableColumn (table, SWT.NONE); columnWithImage.setText ("Image"); int count = 3; for (int i=0; i<count; i++) { TableItem item = new TableItem (table, SWT.NONE); item.setText (0, "Text"); item.setText (1, "Image"); item.setImage(1, createImage()); } columnWithText.pack(); columnWithImage.pack(); shell.pack (); shell.open (); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); } private static Image createImage() { Image image = new Image(Display.getCurrent(), 200, 20); GC gc = new GC(image); gc.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); gc.fillRectangle(image.getBounds()); gc.dispose(); return image; } } // END OF CODE
Retested with SWT 4.19. The issue still occurs.