TableRowSelectionRemove.java Source code

Java tutorial

Introduction

Here is the source code for TableRowSelectionRemove.java

Source

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class TableRowSelectionRemove {

    public static void main(String[] args) {
        Display display = new Display();
        Shell shell = new Shell(display);
        final Table table = new Table(shell, SWT.BORDER | SWT.MULTI);
        table.setSize(200, 200);
        for (int i = 0; i < 128; i++) {
            TableItem item = new TableItem(table, SWT.NONE);
            item.setText("Item " + i);
        }

        table.setSelection(2);

        table.remove(table.getSelectionIndices());

        shell.pack();
        shell.open();
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch())
                display.sleep();
        }
        display.dispose();
    }
}