<?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%2FTable_Editor</id>
		<title>Java Tutorial/SWT/Table Editor - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FSWT%2FTable_Editor"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Editor&amp;action=history"/>
		<updated>2026-04-07T06:10:01Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Editor&amp;diff=3013&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/Table_Editor&amp;diff=3013&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/Table_Editor&amp;diff=3014&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Editor&amp;diff=3014&amp;oldid=prev"/>
				<updated>2010-05-31T15:19:51Z</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 action listener to Table Button Cell Editor ==&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.custom.TableEditor;&lt;br /&gt;
import org.eclipse.swt.events.SelectionAdapter;&lt;br /&gt;
import org.eclipse.swt.events.SelectionEvent;&lt;br /&gt;
import org.eclipse.swt.graphics.Color;&lt;br /&gt;
import org.eclipse.swt.graphics.RGB;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.ColorDialog;&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 TableEditorButtonActionListener {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Text Table Editor&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Table table = new Table(shell, SWT.SINGLE | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.CENTER);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + (i + 1));&lt;br /&gt;
      column.pack();&lt;br /&gt;
    }&lt;br /&gt;
    // Create five table editors for color&lt;br /&gt;
    TableEditor[] colorEditors = new TableEditor[5];&lt;br /&gt;
    // Create five buttons for changing color&lt;br /&gt;
    Button[] colorButtons = new Button[5];&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
      final TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      colorEditors[i] = new TableEditor(table);&lt;br /&gt;
      colorButtons[i] = new Button(table, SWT.PUSH);&lt;br /&gt;
      colorButtons[i].setText(&amp;quot;Color...&amp;quot;);&lt;br /&gt;
      colorButtons[i].ruputeSize(SWT.DEFAULT, table.getItemHeight());&lt;br /&gt;
      colorEditors[i].grabHorizontal = true;&lt;br /&gt;
      colorEditors[i].minimumHeight = colorButtons[i].getSize().y;&lt;br /&gt;
      colorEditors[i].minimumWidth = colorButtons[i].getSize().x;&lt;br /&gt;
      colorEditors[i].setEditor(colorButtons[i], item, 0);&lt;br /&gt;
      &lt;br /&gt;
      colorButtons[i].addSelectionListener(new SelectionAdapter() {&lt;br /&gt;
        public void widgetSelected(SelectionEvent event) {&lt;br /&gt;
          ColorDialog dialog = new ColorDialog(shell);&lt;br /&gt;
          RGB rgb = dialog.open();&lt;br /&gt;
          if (rgb != null) {&lt;br /&gt;
            table.setBackground(new Color(shell.getDisplay(), rgb));&lt;br /&gt;
          }&lt;br /&gt;
        }&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;
    }&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 selection listener to TableCursor ==&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.custom.ControlEditor;&lt;br /&gt;
import org.eclipse.swt.custom.TableCursor;&lt;br /&gt;
import org.eclipse.swt.events.KeyAdapter;&lt;br /&gt;
import org.eclipse.swt.events.KeyEvent;&lt;br /&gt;
import org.eclipse.swt.events.SelectionAdapter;&lt;br /&gt;
import org.eclipse.swt.events.SelectionEvent;&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.TableColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class TableCursorListenerSelection {&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;Table Cursor Test&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Table table = new Table(shell, SWT.SINGLE | SWT.FULL_SELECTION);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.CENTER);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + (i + 1));&lt;br /&gt;
      column.pack();&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
      new TableItem(table, SWT.NONE);&lt;br /&gt;
    }&lt;br /&gt;
    final TableCursor cursor = new TableCursor(table, SWT.NONE);&lt;br /&gt;
    final ControlEditor editor = new ControlEditor(cursor);&lt;br /&gt;
    editor.grabHorizontal = true;&lt;br /&gt;
    editor.grabVertical = true;&lt;br /&gt;
    cursor.addSelectionListener(new SelectionAdapter() {&lt;br /&gt;
      // This is called as the user navigates around the table&lt;br /&gt;
      public void widgetSelected(SelectionEvent event) {&lt;br /&gt;
        // Select the row in the table where the TableCursor is&lt;br /&gt;
        table.setSelection(new TableItem[] { cursor.getRow() });&lt;br /&gt;
      }&lt;br /&gt;
      // This is called when the user hits Enter&lt;br /&gt;
      public void widgetDefaultSelected(SelectionEvent event) {&lt;br /&gt;
        final Text text = new Text(cursor, SWT.NONE);&lt;br /&gt;
        text.setFocus();&lt;br /&gt;
        // Copy the text from the cell to the Text control&lt;br /&gt;
        text.setText(cursor.getRow().getText(cursor.getColumn()));&lt;br /&gt;
        text.setFocus();&lt;br /&gt;
        // Add a handler to detect key presses&lt;br /&gt;
        text.addKeyListener(new KeyAdapter() {&lt;br /&gt;
          public void keyPressed(KeyEvent event) {&lt;br /&gt;
            switch (event.keyCode) {&lt;br /&gt;
            case SWT.CR:&lt;br /&gt;
              cursor.getRow().setText(cursor.getColumn(), text.getText());&lt;br /&gt;
            case SWT.ESC:&lt;br /&gt;
              text.dispose();&lt;br /&gt;
              break;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        });&lt;br /&gt;
        editor.setEditor(text);&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;
    }&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;
==  Edit the text of a table item (in place) ==&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;
 * TableEditor example snippet: edit the text of a table item (in place)&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.custom.TableEditor;&lt;br /&gt;
import org.eclipse.swt.events.ModifyEvent;&lt;br /&gt;
import org.eclipse.swt.events.ModifyListener;&lt;br /&gt;
import org.eclipse.swt.events.SelectionAdapter;&lt;br /&gt;
import org.eclipse.swt.events.SelectionEvent;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Control;&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;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class TableItemEditor {&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.FULL_SELECTION | SWT.HIDE_SELECTION);&lt;br /&gt;
    TableColumn column1 = new TableColumn(table, SWT.NONE);&lt;br /&gt;
    TableColumn column2 = new TableColumn(table, SWT.NONE);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 10; 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;edit this value&amp;quot; });&lt;br /&gt;
    }&lt;br /&gt;
    column1.pack();&lt;br /&gt;
    column2.pack();&lt;br /&gt;
    final TableEditor editor = new TableEditor(table);&lt;br /&gt;
    // The editor must have the same size as the cell and must&lt;br /&gt;
    // not be any smaller than 50 pixels.&lt;br /&gt;
    editor.horizontalAlignment = SWT.LEFT;&lt;br /&gt;
    editor.grabHorizontal = true;&lt;br /&gt;
    editor.minimumWidth = 50;&lt;br /&gt;
    // editing the second column&lt;br /&gt;
    final int EDITABLECOLUMN = 1;&lt;br /&gt;
    table.addSelectionListener(new SelectionAdapter() {&lt;br /&gt;
      public void widgetSelected(SelectionEvent e) {&lt;br /&gt;
        // Clean up any previous editor control&lt;br /&gt;
        Control oldEditor = editor.getEditor();&lt;br /&gt;
        if (oldEditor != null)&lt;br /&gt;
          oldEditor.dispose();&lt;br /&gt;
        // Identify the selected row&lt;br /&gt;
        TableItem item = (TableItem) e.item;&lt;br /&gt;
        if (item == null)&lt;br /&gt;
          return;&lt;br /&gt;
        // The control that will be the editor must be a child of the Table&lt;br /&gt;
        Text newEditor = new Text(table, SWT.NONE);&lt;br /&gt;
        newEditor.setText(item.getText(EDITABLECOLUMN));&lt;br /&gt;
        newEditor.addModifyListener(new ModifyListener() {&lt;br /&gt;
          public void modifyText(ModifyEvent me) {&lt;br /&gt;
            Text text = (Text) editor.getEditor();&lt;br /&gt;
            editor.getItem().setText(EDITABLECOLUMN, text.getText());&lt;br /&gt;
          }&lt;br /&gt;
        });&lt;br /&gt;
        newEditor.selectAll();&lt;br /&gt;
        newEditor.setFocus();&lt;br /&gt;
        editor.setEditor(newEditor, item, EDITABLECOLUMN);&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    shell.setSize(300, 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;
==  Install Table Editor when navigating the Table Cursor ==&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.custom.ControlEditor;&lt;br /&gt;
import org.eclipse.swt.custom.TableCursor;&lt;br /&gt;
import org.eclipse.swt.events.KeyAdapter;&lt;br /&gt;
import org.eclipse.swt.events.KeyEvent;&lt;br /&gt;
import org.eclipse.swt.events.SelectionAdapter;&lt;br /&gt;
import org.eclipse.swt.events.SelectionEvent;&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.TableColumn;&lt;br /&gt;
import org.eclipse.swt.widgets.TableItem;&lt;br /&gt;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class TableCursorTableEditor {&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;Table Cursor Test&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Table table = new Table(shell, SWT.SINGLE | SWT.FULL_SELECTION);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.CENTER);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + (i + 1));&lt;br /&gt;
      column.pack();&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
      new TableItem(table, SWT.NONE);&lt;br /&gt;
    }&lt;br /&gt;
    final TableCursor cursor = new TableCursor(table, SWT.NONE);&lt;br /&gt;
    final ControlEditor editor = new ControlEditor(cursor);&lt;br /&gt;
    editor.grabHorizontal = true;&lt;br /&gt;
    editor.grabVertical = true;&lt;br /&gt;
    cursor.addSelectionListener(new SelectionAdapter() {&lt;br /&gt;
      // This is called as the user navigates around the table&lt;br /&gt;
      public void widgetSelected(SelectionEvent event) {&lt;br /&gt;
        // Select the row in the table where the TableCursor is&lt;br /&gt;
        table.setSelection(new TableItem[] { cursor.getRow() });&lt;br /&gt;
      }&lt;br /&gt;
      // This is called when the user hits Enter&lt;br /&gt;
      public void widgetDefaultSelected(SelectionEvent event) {&lt;br /&gt;
        final Text text = new Text(cursor, SWT.NONE);&lt;br /&gt;
        text.setFocus();&lt;br /&gt;
        // Copy the text from the cell to the Text control&lt;br /&gt;
        text.setText(cursor.getRow().getText(cursor.getColumn()));&lt;br /&gt;
        text.setFocus();&lt;br /&gt;
        // Add a handler to detect key presses&lt;br /&gt;
        text.addKeyListener(new KeyAdapter() {&lt;br /&gt;
          public void keyPressed(KeyEvent event) {&lt;br /&gt;
            switch (event.keyCode) {&lt;br /&gt;
            case SWT.CR:&lt;br /&gt;
              cursor.getRow().setText(cursor.getColumn(), text.getText());&lt;br /&gt;
            case SWT.ESC:&lt;br /&gt;
              text.dispose();&lt;br /&gt;
              break;&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        });&lt;br /&gt;
        editor.setEditor(text);&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;
    }&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;
==  Placing the Text Editor after mouse click and exchange data between table cell and editor ==&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.custom.TableEditor;&lt;br /&gt;
import org.eclipse.swt.events.ModifyEvent;&lt;br /&gt;
import org.eclipse.swt.events.ModifyListener;&lt;br /&gt;
import org.eclipse.swt.events.MouseAdapter;&lt;br /&gt;
import org.eclipse.swt.events.MouseEvent;&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.layout.FillLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Control;&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;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class TableEditorMouseClickText {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setText(&amp;quot;Text Table Editor&amp;quot;);&lt;br /&gt;
    shell.setLayout(new FillLayout());&lt;br /&gt;
    final Table table = new Table(shell, SWT.SINGLE | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);&lt;br /&gt;
    table.setHeaderVisible(true);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.CENTER);&lt;br /&gt;
      column.setText(&amp;quot;Column &amp;quot; + (i + 1));&lt;br /&gt;
      column.pack();&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
      final TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
    }&lt;br /&gt;
    final TableEditor editor = new TableEditor(table);&lt;br /&gt;
    editor.horizontalAlignment = SWT.LEFT;&lt;br /&gt;
    editor.grabHorizontal = true;&lt;br /&gt;
    table.addMouseListener(new MouseAdapter() {&lt;br /&gt;
      public void mouseDown(MouseEvent event) {&lt;br /&gt;
        Control old = editor.getEditor();&lt;br /&gt;
        if (old != null)&lt;br /&gt;
          old.dispose();&lt;br /&gt;
        Point pt = new Point(event.x, event.y);&lt;br /&gt;
        final TableItem item = table.getItem(pt);&lt;br /&gt;
        if (item == null) {&lt;br /&gt;
          return;&lt;br /&gt;
        }&lt;br /&gt;
        int column = -1;&lt;br /&gt;
        for (int i = 0, n = table.getColumnCount(); i &amp;lt; n; i++) {&lt;br /&gt;
          Rectangle rect = item.getBounds(i);&lt;br /&gt;
          if (rect.contains(pt)) {&lt;br /&gt;
            column = i;&lt;br /&gt;
            break;&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        if (column != 1) {&lt;br /&gt;
          return;&lt;br /&gt;
        }&lt;br /&gt;
        final Text text = new Text(table, SWT.NONE);&lt;br /&gt;
        text.setForeground(item.getForeground());&lt;br /&gt;
        text.setText(item.getText(column));&lt;br /&gt;
        text.setForeground(item.getForeground());&lt;br /&gt;
        text.selectAll();&lt;br /&gt;
        text.setFocus();&lt;br /&gt;
        editor.minimumWidth = text.getBounds().width;&lt;br /&gt;
        editor.setEditor(text, item, column);&lt;br /&gt;
        final int col = column;&lt;br /&gt;
        text.addModifyListener(new ModifyListener() {&lt;br /&gt;
          public void modifyText(ModifyEvent event) {&lt;br /&gt;
            item.setText(col, text.getText());&lt;br /&gt;
          }&lt;br /&gt;
        });&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;
    }&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 Cell Editor: Combo, Text and Button ==&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: place arbitrary controls in a table&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.custom.CCombo;&lt;br /&gt;
import org.eclipse.swt.custom.TableEditor;&lt;br /&gt;
import org.eclipse.swt.layout.FillLayout;&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.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;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class TableCellEditorComboTextButton {&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;
    Table table = new Table(shell, SWT.BORDER | SWT.MULTI);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 3; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.NONE);&lt;br /&gt;
      column.setWidth(100);&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; 12; i++) {&lt;br /&gt;
      new TableItem(table, SWT.NONE);&lt;br /&gt;
    }&lt;br /&gt;
    TableItem[] items = table.getItems();&lt;br /&gt;
    for (int i = 0; i &amp;lt; items.length; i++) {&lt;br /&gt;
      TableEditor editor = new TableEditor(table);&lt;br /&gt;
      CCombo combo = new CCombo(table, SWT.NONE);&lt;br /&gt;
      combo.setText(&amp;quot;CCombo&amp;quot;);&lt;br /&gt;
      combo.add(&amp;quot;item 1&amp;quot;);&lt;br /&gt;
      combo.add(&amp;quot;item 2&amp;quot;);&lt;br /&gt;
      editor.grabHorizontal = true;&lt;br /&gt;
      editor.setEditor(combo, items[i], 0);&lt;br /&gt;
      editor = new TableEditor(table);&lt;br /&gt;
      Text text = new Text(table, SWT.NONE);&lt;br /&gt;
      text.setText(&amp;quot;Text&amp;quot;);&lt;br /&gt;
      editor.grabHorizontal = true;&lt;br /&gt;
      editor.setEditor(text, items[i], 1);&lt;br /&gt;
      editor = new TableEditor(table);&lt;br /&gt;
      Button button = new Button(table, SWT.CHECK);&lt;br /&gt;
      button.pack();&lt;br /&gt;
      editor.minimumWidth = button.getSize().x;&lt;br /&gt;
      editor.horizontalAlignment = SWT.LEFT;&lt;br /&gt;
      editor.setEditor(button, items[i], 2);&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;
==  TableEditor: tab and escape 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, 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;
 * TableEditor example snippet: edit a cell in a table (in place, fancy)&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.custom.TableEditor;&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.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;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class TableEditorTabEscapeEvent{&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 | SWT.MULTI);&lt;br /&gt;
    table.setLinesVisible(true);&lt;br /&gt;
    for (int i = 0; i &amp;lt; 3; i++) {&lt;br /&gt;
      TableColumn column = new TableColumn(table, SWT.NONE);&lt;br /&gt;
      column.setWidth(100);&lt;br /&gt;
    }&lt;br /&gt;
    for (int i = 0; i &amp;lt; 3; i++) {&lt;br /&gt;
      TableItem item = new TableItem(table, SWT.NONE);&lt;br /&gt;
      item.setText(new String[] { &amp;quot;&amp;quot; + i, &amp;quot;&amp;quot; + i, &amp;quot;&amp;quot; + i });&lt;br /&gt;
    }&lt;br /&gt;
    final TableEditor editor = new TableEditor(table);&lt;br /&gt;
    editor.horizontalAlignment = SWT.LEFT;&lt;br /&gt;
    editor.grabHorizontal = true;&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;
          final TableItem item = table.getItem(index);&lt;br /&gt;
          for (int i = 0; i &amp;lt; table.getColumnCount(); i++) {&lt;br /&gt;
            Rectangle rect = item.getBounds(i);&lt;br /&gt;
            if (rect.contains(pt)) {&lt;br /&gt;
              final int column = i;&lt;br /&gt;
              final Text text = new Text(table, SWT.NONE);&lt;br /&gt;
              Listener textListener = new Listener() {&lt;br /&gt;
                public void handleEvent(final Event e) {&lt;br /&gt;
                  switch (e.type) {&lt;br /&gt;
                  case SWT.FocusOut:&lt;br /&gt;
                    item.setText(column, text.getText());&lt;br /&gt;
                    text.dispose();&lt;br /&gt;
                    break;&lt;br /&gt;
                  case SWT.Traverse:&lt;br /&gt;
                    switch (e.detail) {&lt;br /&gt;
                    case SWT.TRAVERSE_RETURN:&lt;br /&gt;
                      item.setText(column, text.getText());&lt;br /&gt;
                    // FALL THROUGH&lt;br /&gt;
                    case SWT.TRAVERSE_ESCAPE:&lt;br /&gt;
                      text.dispose();&lt;br /&gt;
                      e.doit = false;&lt;br /&gt;
                    }&lt;br /&gt;
                    break;&lt;br /&gt;
                  }&lt;br /&gt;
                }&lt;br /&gt;
              };&lt;br /&gt;
              text.addListener(SWT.FocusOut, textListener);&lt;br /&gt;
              text.addListener(SWT.Traverse, textListener);&lt;br /&gt;
              editor.setEditor(text, item, i);&lt;br /&gt;
              text.setText(item.getText(i));&lt;br /&gt;
              text.selectAll();&lt;br /&gt;
              text.setFocus();&lt;br /&gt;
              return;&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.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;
==  Using TableEditor ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;TableEditor derives from ControlEditor.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;TableEditor belongs to a cell.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Use the setters for row and column to set the cell, like this:&amp;lt;/LI&amp;gt;&amp;lt;/OL&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;
TableEditor editor = new TableEditor(myTable);&lt;br /&gt;
editor.setEditor(myControl);&lt;br /&gt;
editor.setItem(myItem);&lt;br /&gt;
editor.setColumn(myColumn);&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>