Project: SWT
Bug 12573 Table sends selection event twice when in TabFolder
Reported: 2002-04-01 17:07:48 | Status: resolved fixed

Build 20020328 I had a hard time believing it too. When a Table is created inside a TabFolder, it sends the selection event twice. If it's not in a TabFolder, it only sends it once. The following code shows the problem. Changing the selection generates 2 lines of console output. If you change the Table's parent to be shell, it only generates 1. The lines commented out would normally be used, but aren't needed to show the problem. import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.*; public class TableTest { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new FillLayout()); shell.setSize(400, 300); TabFolder tabFolder = new TabFolder(shell, SWT.NONE); tabFolder.setLayout(new FillLayout()); // TabItem tabItem1 = new TabItem(tabFolder, SWT.NONE); // tabItem1.setText("Tab 1"); final Table table = new Table(tabFolder, SWT.NONE); // tabItem1.setControl(table); table.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { System.out.println(table.getSelectionCount() + " items selected"); } }); for (int i = 0; i < 10; ++i) { TableItem item = new TableItem(table, SWT.NONE); item.setText("Item " + i); } shell.setVisible(true); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } } }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java