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

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/TableColumn&amp;diff=3079&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/TableColumn&amp;diff=3079&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://jexp.ru/index.php?title=Java_Tutorial/SWT/TableColumn&amp;diff=3080&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/TableColumn&amp;diff=3080&amp;oldid=prev"/>
				<updated>2010-05-31T15:20:24Z</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 Column Header Selection 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, 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: sort a table by column&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 java.text.Collator;&lt;br /&gt;
import java.util.Locale;&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.TableColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableColumnSelectionListener {&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 FillLayout());&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    final TableColumn column1 = new TableColumn(table, SWT.NONE);&lt;br /&gt;
    column1.setText(&amp;quot;Column 1&amp;quot;);&lt;br /&gt;
    final TableColumn column2 = new TableColumn(table, SWT.NONE);&lt;br /&gt;
    column2.setText(&amp;quot;Column 2&amp;quot;);&lt;br /&gt;
    TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
    item.setText(new String[] { &amp;quot;a&amp;quot;, &amp;quot;3&amp;quot; });&lt;br /&gt;
    item = new TableItem(table, SWT.NONE);&lt;br /&gt;
    item.setText(new String[] { &amp;quot;b&amp;quot;, &amp;quot;2&amp;quot; });&lt;br /&gt;
    item = new TableItem(table, SWT.NONE);&lt;br /&gt;
    item.setText(new String[] { &amp;quot;c&amp;quot;, &amp;quot;1&amp;quot; });&lt;br /&gt;
    column1.setWidth(100);&lt;br /&gt;
    column2.setWidth(100);&lt;br /&gt;
    Listener sortListener = new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        TableColumn column = (TableColumn) e.widget;&lt;br /&gt;
        System.out.println(column);&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    column1.addListener(SWT.Selection, sortListener);&lt;br /&gt;
    column2.addListener(SWT.Selection, sortListener);&lt;br /&gt;
    shell.setSize(shell.ruputeSize(SWT.DEFAULT, SWT.DEFAULT).x, 300);&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 Icon to Table column ==&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.graphics.GC;&lt;br /&gt;
import org.eclipse.swt.graphics.Image;&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.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Table;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
public class TableColumnIcon {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    final Image image = new Image(display, 16, 16);&lt;br /&gt;
    GC gc = new GC(image);&lt;br /&gt;
    gc.setBackground(display.getSystemColor(SWT.COLOR_RED));&lt;br /&gt;
    gc.fillRectangle(image.getBounds());&lt;br /&gt;
    gc.dispose();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Lazy Table&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI);&lt;br /&gt;
    table.setSize(200, 200);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 20; i++) {&lt;br /&gt;
      final int[] index = new int[] { i };&lt;br /&gt;
      TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      item.setText(&amp;quot;Table Item &amp;quot; + index[0]);&lt;br /&gt;
      item.setImage(image);&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;
    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;
==  Adding Columns ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The TableColumn class represents a column in the table. &lt;br /&gt;
You create a column with a parent table, a style, and optionally an index. &lt;br /&gt;
If you don&amp;quot;t specify an index, the column assumes the next available zero-based index.&amp;lt;/p&amp;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;
public TableColumn(Table parent, int style)&lt;br /&gt;
public TableColumn(Table parent, int style, int index)&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;
==  Fixed first column and horizontal scroll remaining columns ==&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: Fixed first column and horizontal scroll remaining columns&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;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.GC;&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.layout.GridData;&lt;br /&gt;
import org.eclipse.swt.layout.GridLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.ruposite;&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.Label;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.ScrollBar;&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 TableColumnFirstFix {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    int rowCount = 40;&lt;br /&gt;
    int columnCount = 15;&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;
    Composite parent = new Composite(shell, SWT.BORDER);&lt;br /&gt;
    GridLayout layout = new GridLayout(2, false);&lt;br /&gt;
    layout.marginWidth = layout.marginHeight = layout.horizontalSpacing = 0;&lt;br /&gt;
    parent.setLayout(layout);&lt;br /&gt;
    final Table leftTable = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION);&lt;br /&gt;
    leftTable.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));&lt;br /&gt;
    leftTable.setHeaderVisible(true);&lt;br /&gt;
    final Table rightTable = new Table(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL&lt;br /&gt;
        | SWT.FULL_SELECTION);&lt;br /&gt;
    rightTable.setHeaderVisible(true);&lt;br /&gt;
    GridData table2Data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2);&lt;br /&gt;
    rightTable.setLayoutData(table2Data);&lt;br /&gt;
    // Create columns&lt;br /&gt;
    TableColumn column1 = new TableColumn(leftTable, SWT.NONE);&lt;br /&gt;
    column1.setText(&amp;quot;Name&amp;quot;);&lt;br /&gt;
    column1.setWidth(150);&lt;br /&gt;
    for (int i = 0; i &amp;lt; columnCount; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(rightTable, SWT.NONE);&lt;br /&gt;
      column.setText(&amp;quot;Value &amp;quot; + i);&lt;br /&gt;
      column.setWidth(200);&lt;br /&gt;
    }&lt;br /&gt;
    // Create rows&lt;br /&gt;
    for (int i = 0; i &amp;lt; rowCount; i++) {&lt;br /&gt;
      TableItem item = new TableItem(leftTable, SWT.NONE);&lt;br /&gt;
      item.setText(&amp;quot;item &amp;quot; + i);&lt;br /&gt;
      item = new TableItem(rightTable, 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; value @ &amp;quot; + j);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    // Make selection the same in both tables&lt;br /&gt;
    leftTable.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        rightTable.setSelection(leftTable.getSelectionIndices());&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    rightTable.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        leftTable.setSelection(rightTable.getSelectionIndices());&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    // On Windows, the selection is gray if the table does not have focus.&lt;br /&gt;
    // To make both tables appear in focus, draw teh selection background here.&lt;br /&gt;
    // This part only works on version 3.2 or later.&lt;br /&gt;
    Listener eraseListener = new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        if ((event.detail &amp;amp; SWT.SELECTED) != 0) {&lt;br /&gt;
          GC gc = event.gc;&lt;br /&gt;
          Rectangle rect = event.getBounds();&lt;br /&gt;
          gc.setForeground(display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT));&lt;br /&gt;
          gc.setBackground(display.getSystemColor(SWT.COLOR_LIST_SELECTION));&lt;br /&gt;
          gc.fillRectangle(rect);&lt;br /&gt;
          event.detail &amp;amp;= ~SWT.SELECTED;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    };&lt;br /&gt;
    leftTable.addListener(SWT.EraseItem, eraseListener);&lt;br /&gt;
    rightTable.addListener(SWT.EraseItem, eraseListener);&lt;br /&gt;
    // Make vertical scrollbars scroll together&lt;br /&gt;
    ScrollBar vBarLeft = leftTable.getVerticalBar();&lt;br /&gt;
    vBarLeft.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        rightTable.setTopIndex(leftTable.getTopIndex());&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    ScrollBar vBarRight = rightTable.getVerticalBar();&lt;br /&gt;
    vBarRight.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event event) {&lt;br /&gt;
        leftTable.setTopIndex(rightTable.getTopIndex());&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    // Horizontal bar on second table takes up a little extra space.&lt;br /&gt;
    // To keep vertical scroll bars in sink, force table1 to end above&lt;br /&gt;
    // horizontal scrollbar&lt;br /&gt;
    ScrollBar hBarRight = rightTable.getHorizontalBar();&lt;br /&gt;
    Label spacer = new Label(parent, SWT.NONE);&lt;br /&gt;
    GridData spacerData = new GridData();&lt;br /&gt;
    spacerData.heightHint = hBarRight.getSize().y;&lt;br /&gt;
    spacer.setVisible(false);&lt;br /&gt;
    parent.setBackground(leftTable.getBackground());&lt;br /&gt;
    shell.setSize(600, 400);&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;
==  Insert a table column at an index ==&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: insert a table column (at an index)&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.layout.RowLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&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 TableColumnInsert {&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.VERTICAL));&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 4; 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;
    final TableColumn[] columns = table.getColumns();&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;
      for (int j = 0; j &amp;lt; columns.length; j++) {&lt;br /&gt;
        item.setText(j, &amp;quot;Item &amp;quot; + i);&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; columns.length; i++)&lt;br /&gt;
      columns[i].pack();&lt;br /&gt;
    int index = 1;&lt;br /&gt;
    TableColumn column = new TableColumn(table, SWT.NONE, index);&lt;br /&gt;
    column.setText(&amp;quot;Column &amp;quot; + index + &amp;quot;a&amp;quot;);&lt;br /&gt;
    TableItem[] items = table.getItems();&lt;br /&gt;
    for (int i = 0; i &amp;lt; items.length; i++) {&lt;br /&gt;
      items[i].setText(index, &amp;quot;Item &amp;quot; + i + &amp;quot;a&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    column.pack();&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;
==  Reorder TableColumn ==&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 TableColumnReorder {&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;
    Button b = new Button(shell, SWT.PUSH);&lt;br /&gt;
    b.setText(&amp;quot;invert column order&amp;quot;);&lt;br /&gt;
    b.addListener(SWT.Selection, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        int[] order = table.getColumnOrder();&lt;br /&gt;
        for (int i = 0; i &amp;lt; order.length / 2; i++) {&lt;br /&gt;
          int temp = order[i];&lt;br /&gt;
          order[i] = order[order.length - i - 1];&lt;br /&gt;
          order[order.length - i - 1] = temp;&lt;br /&gt;
        }&lt;br /&gt;
        table.setColumnOrder(order);&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;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>