<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FTable_Event</id>
		<title>Java Tutorial/SWT/Table Event - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FTable_Event"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Event&amp;action=history"/>
		<updated>2026-04-21T12:47:21Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Event&amp;diff=3005&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Event&amp;diff=3005&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:26Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 17:44, 31 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Event&amp;diff=3006&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Event&amp;diff=3006&amp;oldid=prev"/>
				<updated>2010-05-31T15:19:49Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Add Default Table Selection Listener and Get the Selected TableItem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableDefaultSelectionListener {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 16; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, 0);&lt;br /&gt;
      item.setText(&amp;quot;Item &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    table.setBounds(0, 0, 100, 100);&lt;br /&gt;
    table.addListener(SWT.DefaultSelection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        String string = &amp;quot;&amp;quot;;&lt;br /&gt;
        TableItem[] selection = table.getSelection();&lt;br /&gt;
        for (int i = 0; i &amp;lt; selection.length; i++)&lt;br /&gt;
          string += selection[i] + &amp;quot; &amp;quot;;&lt;br /&gt;
        System.out.println(&amp;quot;DefaultSelection={&amp;quot; + string + &amp;quot;}&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Add Table Selection Listener and Get Selected TableItem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableSelectionListenerSelectedTableItem {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 16; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, 0);&lt;br /&gt;
      item.setText(&amp;quot;Item &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    table.setBounds(0, 0, 100, 100);&lt;br /&gt;
    table.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        String string = &amp;quot;&amp;quot;;&lt;br /&gt;
        TableItem[] selection = table.getSelection();&lt;br /&gt;
        for (int i = 0; i &amp;lt; selection.length; i++)&lt;br /&gt;
          string += selection[i] + &amp;quot; &amp;quot;;&lt;br /&gt;
        System.out.println(&amp;quot;Selection={&amp;quot; + string + &amp;quot;}&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Find a table cell from mouse down (works for any table style) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2004 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * Table example snippet: find a table cell from mouse down (works for any table style)&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableCellUnderMouse {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.V_SCROLL);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    final int rowCount = 64, columnCount = 4;&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.NONE);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; rowCount; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      for (int j = 0; j &amp;lt; columnCount; j++) {&lt;br /&gt;
        item.setText(j, &amp;quot;Item &amp;quot; + i + &amp;quot;-&amp;quot; + j);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      table.getColumn(i).pack();&lt;br /&gt;
    }&lt;br /&gt;
    Point size = table.ruputeSize(SWT.DEFAULT, 200);&lt;br /&gt;
    table.setSize(size);&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    table.addListener(SWT.MouseDown, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        Rectangle clientArea = table.getClientArea();&lt;br /&gt;
        Point pt = new Point(event.x, event.y);&lt;br /&gt;
        int index = table.getTopIndex();&lt;br /&gt;
        while (index &amp;lt; table.getItemCount()) {&lt;br /&gt;
          boolean visible = false;&lt;br /&gt;
          TableItem item = table.getItem(index);&lt;br /&gt;
          for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
            Rectangle rect = item.getBounds(i);&lt;br /&gt;
            if (rect.contains(pt)) {&lt;br /&gt;
              System.out.println(&amp;quot;Item &amp;quot; + index + &amp;quot;-&amp;quot; + i);&lt;br /&gt;
            }&lt;br /&gt;
            if (!visible &amp;amp;&amp;amp; rect.intersects(clientArea)) {&lt;br /&gt;
              visible = true;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
          if (!visible)&lt;br /&gt;
            return;&lt;br /&gt;
          index++;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Get TableItem from Mouse position ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2004 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * Table example snippet: find a table cell from mouse down (SWT.FULL_SELECTION)&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableItemMouse {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    final int rowCount = 64, columnCount = 4;&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.NONE);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; rowCount; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      for (int j = 0; j &amp;lt; columnCount; j++) {&lt;br /&gt;
        item.setText(j, &amp;quot;Item &amp;quot; + i + &amp;quot;-&amp;quot; + j);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      table.getColumn(i).pack();&lt;br /&gt;
    }&lt;br /&gt;
    Point size = table.ruputeSize(SWT.DEFAULT, 200);&lt;br /&gt;
    table.setSize(size);&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    table.addListener(SWT.MouseDown, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        Point pt = new Point(event.x, event.y);&lt;br /&gt;
        TableItem item = table.getItem(pt);&lt;br /&gt;
        if (item == null)&lt;br /&gt;
          return;&lt;br /&gt;
        for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
          Rectangle rect = item.getBounds(i);&lt;br /&gt;
          if (rect.contains(pt)) {&lt;br /&gt;
            int index = table.indexOf(item);&lt;br /&gt;
            System.out.println(&amp;quot;Item &amp;quot; + index + &amp;quot;-&amp;quot; + i);&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  TableColumn Move Listener ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * Allow user to reorder columns and reorder columns programmatically.&lt;br /&gt;
 * &lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.1&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.RowData;&lt;br /&gt;
import org.eclipse.swt.layout.RowLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableColumnMoveListener {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new RowLayout(SWT.HORIZONTAL));&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.CHECK);&lt;br /&gt;
    table.setLayoutData(new RowData(-1, 300));&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    TableColumn column = new TableColumn(table, SWT.LEFT);&lt;br /&gt;
    column.setText(&amp;quot;Column 0&amp;quot;);&lt;br /&gt;
    column = new TableColumn(table, SWT.CENTER);&lt;br /&gt;
    column.setText(&amp;quot;Column 1&amp;quot;);&lt;br /&gt;
    column = new TableColumn(table, SWT.CENTER);&lt;br /&gt;
    column.setText(&amp;quot;Column 2&amp;quot;);&lt;br /&gt;
    column = new TableColumn(table, SWT.CENTER);&lt;br /&gt;
    column.setText(&amp;quot;Column 3&amp;quot;);&lt;br /&gt;
    column = new TableColumn(table, SWT.CENTER);&lt;br /&gt;
    column.setText(&amp;quot;Column 4&amp;quot;);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 100; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      String[] text = new String[] { i + &amp;quot; 0&amp;quot;, i + &amp;quot; 1&amp;quot;, i + &amp;quot; 2&amp;quot;, i + &amp;quot; 3&amp;quot;, i + &amp;quot; 4&amp;quot; };&lt;br /&gt;
      item.setText(text);&lt;br /&gt;
    }&lt;br /&gt;
    Listener listener = new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        System.out.println(&amp;quot;Move &amp;quot; + e.widget);&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    TableColumn[] columns = table.getColumns();&lt;br /&gt;
    for (int i = 0; i &amp;lt; columns.length; i++) {&lt;br /&gt;
      columns[i].pack();&lt;br /&gt;
      columns[i].setMoveable(true);&lt;br /&gt;
      columns[i].addListener(SWT.Move, listener);&lt;br /&gt;
    }&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Table events: MeasureItem, PaintItem and EraseItem ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2006 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/* &lt;br /&gt;
 * example snippet: Multiple lines per TableItem&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.2&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableEventMeasureItemPaintItemEraseItem {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Multiple lines in a TableItem&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    int columnCount = 4;&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.NONE);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    int itemCount = 8;&lt;br /&gt;
    for (int i = 0; i &amp;lt; itemCount; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      item.setText(new String[] { &amp;quot;item &amp;quot; + i + &amp;quot; a&amp;quot;, &amp;quot;item &amp;quot; + i + &amp;quot; b&amp;quot;, &amp;quot;item &amp;quot; + i + &amp;quot; c&amp;quot;,&lt;br /&gt;
          &amp;quot;item &amp;quot; + i + &amp;quot; d&amp;quot; });&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.&lt;br /&gt;
     * Therefore, it is critical for performance that these methods be as&lt;br /&gt;
     * efficient as possible.&lt;br /&gt;
     */&lt;br /&gt;
    Listener paintListener = new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        switch (event.type) {&lt;br /&gt;
        case SWT.MeasureItem: {&lt;br /&gt;
          TableItem item = (TableItem) event.item;&lt;br /&gt;
          String text = getText(item, event.index);&lt;br /&gt;
          Point size = event.gc.textExtent(text);&lt;br /&gt;
          event.width = size.x;&lt;br /&gt;
          event.height = Math.max(event.height, size.y);&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        case SWT.PaintItem: {&lt;br /&gt;
          TableItem item = (TableItem) event.item;&lt;br /&gt;
          String text = getText(item, event.index);&lt;br /&gt;
          Point size = event.gc.textExtent(text);&lt;br /&gt;
          int offset2 = event.index == 0 ? Math.max(0, (event.height - size.y) / 2) : 0;&lt;br /&gt;
          event.gc.drawText(text, event.x, event.y + offset2, true);&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        case SWT.EraseItem: {&lt;br /&gt;
          event.detail &amp;amp;= ~SWT.FOREGROUND;&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      String getText(TableItem item, int column) {&lt;br /&gt;
        String text = item.getText(column);&lt;br /&gt;
        if (column != 0) {&lt;br /&gt;
          int index = table.indexOf(item);&lt;br /&gt;
          if ((index + column) % 3 == 1) {&lt;br /&gt;
            text += &amp;quot;\nnew line&amp;quot;;&lt;br /&gt;
          }&lt;br /&gt;
          if ((index + column) % 3 == 2) {&lt;br /&gt;
            text += &amp;quot;\nnew line\nnew line&amp;quot;;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        return text;&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    table.addListener(SWT.MeasureItem, paintListener);&lt;br /&gt;
    table.addListener(SWT.PaintItem, paintListener);&lt;br /&gt;
    table.addListener(SWT.EraseItem, paintListener);&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      table.getColumn(i).pack();&lt;br /&gt;
    }&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Table measure item listener ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2006 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/* &lt;br /&gt;
 * Table example snippet: Images on the right hand side of a TableItem&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.2&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableMeasureItemListener {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Image image = display.getSystemImage(SWT.ICON_INFORMATION);&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Images on the right side of the TableItem&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    int columnCount = 3;&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.NONE);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    int itemCount = 8;&lt;br /&gt;
    for (int i = 0; i &amp;lt; itemCount; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      item.setText(new String[] { &amp;quot;item &amp;quot; + i + &amp;quot; a&amp;quot;, &amp;quot;item &amp;quot; + i + &amp;quot; b&amp;quot;, &amp;quot;item &amp;quot; + i + &amp;quot; c&amp;quot; });&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.&lt;br /&gt;
     * Therefore, it is critical for performance that these methods be as&lt;br /&gt;
     * efficient as possible.&lt;br /&gt;
     */&lt;br /&gt;
    Listener paintListener = new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        switch (event.type) {&lt;br /&gt;
        case SWT.MeasureItem: {&lt;br /&gt;
          Rectangle rect = image.getBounds();&lt;br /&gt;
          event.width += rect.width;&lt;br /&gt;
          event.height = Math.max(event.height, rect.height + 2);&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        case SWT.PaintItem: {&lt;br /&gt;
          int x = event.x + event.width;&lt;br /&gt;
          Rectangle rect = image.getBounds();&lt;br /&gt;
          int offset = Math.max(0, (event.height - rect.height) / 2);&lt;br /&gt;
          event.gc.drawImage(image, x, event.y + offset);&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    table.addListener(SWT.MeasureItem, paintListener);&lt;br /&gt;
    table.addListener(SWT.PaintItem, paintListener);&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      table.getColumn(i).pack();&lt;br /&gt;
    }&lt;br /&gt;
    shell.setSize(500, 200);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    if (image != null)&lt;br /&gt;
      image.dispose();&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Table paint item listener ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2006 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/* &lt;br /&gt;
 * Table example snippet: Images on the right hand side of a TableItem&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.2&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TablePaintItemListener {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Image image = display.getSystemImage(SWT.ICON_INFORMATION);&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Images on the right side of the TableItem&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    int columnCount = 3;&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.NONE);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    int itemCount = 8;&lt;br /&gt;
    for (int i = 0; i &amp;lt; itemCount; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      item.setText(new String[] { &amp;quot;item &amp;quot; + i + &amp;quot; a&amp;quot;, &amp;quot;item &amp;quot; + i + &amp;quot; b&amp;quot;, &amp;quot;item &amp;quot; + i + &amp;quot; c&amp;quot; });&lt;br /&gt;
    }&lt;br /&gt;
    /*&lt;br /&gt;
     * NOTE: MeasureItem, PaintItem and EraseItem are called repeatedly.&lt;br /&gt;
     * Therefore, it is critical for performance that these methods be as&lt;br /&gt;
     * efficient as possible.&lt;br /&gt;
     */&lt;br /&gt;
    Listener paintListener = new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        switch (event.type) {&lt;br /&gt;
        case SWT.MeasureItem: {&lt;br /&gt;
          Rectangle rect = image.getBounds();&lt;br /&gt;
          event.width += rect.width;&lt;br /&gt;
          event.height = Math.max(event.height, rect.height + 2);&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        case SWT.PaintItem: {&lt;br /&gt;
          int x = event.x + event.width;&lt;br /&gt;
          Rectangle rect = image.getBounds();&lt;br /&gt;
          int offset = Math.max(0, (event.height - rect.height) / 2);&lt;br /&gt;
          event.gc.drawImage(image, x, event.y + offset);&lt;br /&gt;
          break;&lt;br /&gt;
        }&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    table.addListener(SWT.MeasureItem, paintListener);&lt;br /&gt;
    table.addListener(SWT.PaintItem, paintListener);&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      table.getColumn(i).pack();&lt;br /&gt;
    }&lt;br /&gt;
    shell.setSize(500, 200);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    if (image != null)&lt;br /&gt;
      image.dispose();&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Table Selection Event ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableSelectionEvent {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    Table table = new Table(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 12; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      item.setText(&amp;quot;Item &amp;quot; + i);&lt;br /&gt;
    }&lt;br /&gt;
    table.setSize(100, 100);&lt;br /&gt;
    table.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        String string = event.detail == SWT.CHECK ? &amp;quot;Checked&amp;quot; : &amp;quot;Selected&amp;quot;;&lt;br /&gt;
        System.out.println(event.item + &amp;quot; &amp;quot; + string);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    &lt;br /&gt;
    shell.setSize(200, 200);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Table SetData Event ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2005 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * Create a virtual table and add 1000 entries to it every 500 ms.&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 * &lt;br /&gt;
 * @since 3.0&lt;br /&gt;
 */&lt;br /&gt;
import java.util.Random;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableSetDataEvent {&lt;br /&gt;
  static int[] data = new int[0];&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.VIRTUAL);&lt;br /&gt;
    table.addListener(SWT.SetData, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        System.out.println(e);&lt;br /&gt;
        TableItem item = (TableItem) e.item;&lt;br /&gt;
        int index = table.indexOf(item);&lt;br /&gt;
        item.setText(&amp;quot;Item &amp;quot; + data[index]);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    int count = 0;&lt;br /&gt;
    Random random = new Random();&lt;br /&gt;
    while (count++ &amp;lt; 50) {&lt;br /&gt;
      int grow = 10;&lt;br /&gt;
      int[] newData = new int[data.length + grow];&lt;br /&gt;
      System.arraycopy(data, 0, newData, 0, data.length);&lt;br /&gt;
      int index = data.length;&lt;br /&gt;
      data = newData;&lt;br /&gt;
      for (int j = 0; j &amp;lt; grow; j++) {&lt;br /&gt;
        data[index++] = random.nextInt();&lt;br /&gt;
      }&lt;br /&gt;
      table.setItemCount(data.length);&lt;br /&gt;
      table.clearAll();&lt;br /&gt;
    }&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>