Project: SWT
Bug 29910 Checkbox not displayed until table scrolled
Reported: 2003-01-21 13:48:33 | Status: resolved fixed

The example code below shows the problem: the checkboxes do not show up unless/until the table is scrolled. The issue is that the TableEditor is being set up before the shell is opened, meaning the Table doesn't have valid bounds yet. When the table does finally show, the cell editors are _not_ being asked to resize to the new, correct bounds of the table, causing them to not show up at all. To observe the problem, just start up the code and look for checkboxes: there are none. As soon as a scroll bar is clicked (and released, this bug is one of two I'm adding), they'll show up. ___CODE___ import org.eclipse.swt.SWT; import org.eclipse.swt.custom.TableEditor; import org.eclipse.swt.widgets.Button; 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 TableEditorTest { private static int NUM_ROWS = 20; public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); Table table = new Table(shell, SWT.BORDER | SWT.MULTI); table.setBounds(10, 10, 400, 200); table.setLinesVisible(true); new TableColumn(table, SWT.NONE).setWidth(100); new TableColumn(table, SWT.NONE).setWidth(100); new TableColumn(table, SWT.NONE).setWidth(100); for (int i = 0; i < NUM_ROWS; i++) { TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] { "" + i, "", "" + i}); } TableItem[] items = table.getItems(); for (int i = 0; i < items.length; i++) { TableEditor editor = new TableEditor(table); Button check = new Button(table, SWT.CHECK); check.setBackground(table.getBackground()); editor.setEditor(check, items[i], 1); editor.grabHorizontal = true; } shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java