Bug 75268 snippet 2
I noticed that if I wanted to replace the static creation of the table items and create it dynamically with a "for" loop, that a "widget disposed" type exception is thrown from line "items[i].dispose();" at line 541 of snippet 2 located under "inserting a row in a table" if clicking the second column to perform a sort. I am wondering if there is a reference issue in the Table. If you replace the static creation of the TableItems with the dynamic creation used in a "for" loop you will see that the exception is thrown. Replace: TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] {"a", "6"}); item = new TableItem(table, SWT.NONE); item.setText(new String[] {"d", "1"}); item = new TableItem(table, SWT.NONE); item.setText(new String[] {"a", "5"}); item = new TableItem(table, SWT.NONE); item.setText(new String[] {"a", "4"}); item = new TableItem(table, SWT.NONE); item.setText(new String[] {"b", "3"}); item = new TableItem(table, SWT.NONE); item.setText(new String[] {"c", "2"}); with: for(int k = 12; k > 0; k--) { TableItem item = new TableItem(table, SWT.NONE); item.setText(new String[] {"a", String.valueOf(k)}); } then click on column 2 to sort the numbers.
examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet2.java
/*******************************************************************************
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.swt.snippets;
/*
 * Table example snippet: sort a table by column
 *
 * For a list of all SWT example snippets see
 * http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets
 */
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import java.text.*;
import java.util.*;
public class Snippet2 {
public static void main (String [] args) {
    Display display = new Display ();
    Shell shell = new Shell (display);
    shell.setLayout(new FillLayout());
    final Table table = new Table(shell, SWT.BORDER);
    table.setHeaderVisible(true);