<?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_Cursor</id>
		<title>Java Tutorial/SWT/Table Cursor - История изменений</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_Cursor"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Cursor&amp;action=history"/>
		<updated>2026-04-10T13:02:55Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/Table_Cursor&amp;diff=3205&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_Cursor&amp;diff=3205&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_Cursor&amp;diff=3206&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_Cursor&amp;diff=3206&amp;oldid=prev"/>
				<updated>2010-05-31T15:22:02Z</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;==  TableCursor ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;TableCursor provides a means to navigate around a table widget using the keyboard:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;Arrows&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Home&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;End&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Page Up&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Page Down&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Enter&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;TableCursor has a single constructor:public TableCursor(Table parent, int style)&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;The style can be either SWT.NONE or SWT.BORDER.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  TableCursor Key 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;
 * TableCursor example snippet: navigate a table cells with arrow keys. &lt;br /&gt;
 * Edit when user hits Return key.  Exit edit mode by hitting Escape (cancels edit)&lt;br /&gt;
 * or Return (applies edit to 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.ControlEditor;&lt;br /&gt;
import org.eclipse.swt.custom.TableCursor;&lt;br /&gt;
import org.eclipse.swt.events.FocusAdapter;&lt;br /&gt;
import org.eclipse.swt.events.FocusEvent;&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.MouseAdapter;&lt;br /&gt;
import org.eclipse.swt.events.MouseEvent;&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.GridData;&lt;br /&gt;
import org.eclipse.swt.layout.GridLayout;&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 TableCursorKeyEvent {&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 GridLayout());&lt;br /&gt;
    // create a a table with 3 columns and fill with data&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);&lt;br /&gt;
    table.setLayoutData(new GridData(GridData.FILL_BOTH));&lt;br /&gt;
    TableColumn column1 = new TableColumn(table, SWT.NONE);&lt;br /&gt;
    TableColumn column2 = new TableColumn(table, SWT.NONE);&lt;br /&gt;
    TableColumn column3 = new TableColumn(table, SWT.NONE);&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;
      item.setText(new String[] { &amp;quot;cell &amp;quot; + i + &amp;quot; 0&amp;quot;, &amp;quot;cell &amp;quot; + i + &amp;quot; 1&amp;quot;, &amp;quot;cell &amp;quot; + i + &amp;quot; 2&amp;quot; });&lt;br /&gt;
    }&lt;br /&gt;
    column1.pack();&lt;br /&gt;
    column2.pack();&lt;br /&gt;
    column3.pack();&lt;br /&gt;
    // create a TableCursor to navigate around the table&lt;br /&gt;
    final TableCursor cursor = new TableCursor(table, SWT.NONE);&lt;br /&gt;
    // create an editor to edit the cell when the user hits &amp;quot;ENTER&amp;quot;&lt;br /&gt;
    // while over a cell in the table&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;
      // when the TableEditor is over a cell, select the corresponding row in&lt;br /&gt;
      // the table&lt;br /&gt;
      public void widgetSelected(SelectionEvent e) {&lt;br /&gt;
        table.setSelection(new TableItem[] { cursor.getRow() });&lt;br /&gt;
      }&lt;br /&gt;
      // when the user hits &amp;quot;ENTER&amp;quot; in the TableCursor, pop up a text editor so&lt;br /&gt;
      // that&lt;br /&gt;
      // they can change the text of the cell&lt;br /&gt;
      public void widgetDefaultSelected(SelectionEvent e) {&lt;br /&gt;
        final Text text = new Text(cursor, SWT.NONE);&lt;br /&gt;
        TableItem row = cursor.getRow();&lt;br /&gt;
        int column = cursor.getColumn();&lt;br /&gt;
        text.setText(row.getText(column));&lt;br /&gt;
        text.addKeyListener(new KeyAdapter() {&lt;br /&gt;
          public void keyPressed(KeyEvent e) {&lt;br /&gt;
            // close the text editor and copy the data over&lt;br /&gt;
            // when the user hits &amp;quot;ENTER&amp;quot;&lt;br /&gt;
            if (e.character == SWT.CR) {&lt;br /&gt;
              TableItem row = cursor.getRow();&lt;br /&gt;
              int column = cursor.getColumn();&lt;br /&gt;
              row.setText(column, text.getText());&lt;br /&gt;
              text.dispose();&lt;br /&gt;
            }&lt;br /&gt;
            // close the text editor when the user hits &amp;quot;ESC&amp;quot;&lt;br /&gt;
            if (e.character == SWT.ESC) {&lt;br /&gt;
              text.dispose();&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        });&lt;br /&gt;
        // close the text editor when the user tabs away&lt;br /&gt;
        text.addFocusListener(new FocusAdapter() {&lt;br /&gt;
          public void focusLost(FocusEvent e) {&lt;br /&gt;
            text.dispose();&lt;br /&gt;
          }&lt;br /&gt;
        });&lt;br /&gt;
        editor.setEditor(text);&lt;br /&gt;
        text.setFocus();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    // Hide the TableCursor when the user hits the &amp;quot;CTRL&amp;quot; or &amp;quot;SHIFT&amp;quot; key.&lt;br /&gt;
    // This alows the user to select multiple items in the table.&lt;br /&gt;
    cursor.addKeyListener(new KeyAdapter() {&lt;br /&gt;
      public void keyPressed(KeyEvent e) {&lt;br /&gt;
        if (e.keyCode == SWT.CTRL || e.keyCode == SWT.SHIFT || (e.stateMask &amp;amp; SWT.CONTROL) != 0&lt;br /&gt;
            || (e.stateMask &amp;amp; SWT.SHIFT) != 0) {&lt;br /&gt;
          cursor.setVisible(false);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    // Show the TableCursor when the user releases the &amp;quot;SHIFT&amp;quot; or &amp;quot;CTRL&amp;quot; key.&lt;br /&gt;
    // This signals the end of the multiple selection task.&lt;br /&gt;
    table.addKeyListener(new KeyAdapter() {&lt;br /&gt;
      public void keyReleased(KeyEvent e) {&lt;br /&gt;
        if (e.keyCode == SWT.CONTROL &amp;amp;&amp;amp; (e.stateMask &amp;amp; SWT.SHIFT) != 0)&lt;br /&gt;
          return;&lt;br /&gt;
        if (e.keyCode == SWT.SHIFT &amp;amp;&amp;amp; (e.stateMask &amp;amp; SWT.CONTROL) != 0)&lt;br /&gt;
          return;&lt;br /&gt;
        if (e.keyCode != SWT.CONTROL &amp;amp;&amp;amp; (e.stateMask &amp;amp; SWT.CONTROL) != 0)&lt;br /&gt;
          return;&lt;br /&gt;
        if (e.keyCode != SWT.SHIFT &amp;amp;&amp;amp; (e.stateMask &amp;amp; SWT.SHIFT) != 0)&lt;br /&gt;
          return;&lt;br /&gt;
        TableItem[] selection = table.getSelection();&lt;br /&gt;
        TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];&lt;br /&gt;
        table.showItem(row);&lt;br /&gt;
        cursor.setSelection(row, 0);&lt;br /&gt;
        cursor.setVisible(true);&lt;br /&gt;
        cursor.setFocus();&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;
==  TableCursor Mouse 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;
 * TableCursor example snippet: navigate a table cells with arrow keys. &lt;br /&gt;
 * Edit when user hits Return key.  Exit edit mode by hitting Escape (cancels edit)&lt;br /&gt;
 * or Return (applies edit to 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.ControlEditor;&lt;br /&gt;
import org.eclipse.swt.custom.TableCursor;&lt;br /&gt;
import org.eclipse.swt.events.FocusAdapter;&lt;br /&gt;
import org.eclipse.swt.events.FocusEvent;&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.MouseAdapter;&lt;br /&gt;
import org.eclipse.swt.events.MouseEvent;&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.GridData;&lt;br /&gt;
import org.eclipse.swt.layout.GridLayout;&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 TableCursorMouseEvent {&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 GridLayout());&lt;br /&gt;
    // create a a table with 3 columns and fill with data&lt;br /&gt;
    final Table table = new Table(shell, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);&lt;br /&gt;
    table.setLayoutData(new GridData(GridData.FILL_BOTH));&lt;br /&gt;
    TableColumn column1 = new TableColumn(table, SWT.NONE);&lt;br /&gt;
    TableColumn column2 = new TableColumn(table, SWT.NONE);&lt;br /&gt;
    TableColumn column3 = new TableColumn(table, SWT.NONE);&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;
      item.setText(new String[] { &amp;quot;cell &amp;quot; + i + &amp;quot; 0&amp;quot;, &amp;quot;cell &amp;quot; + i + &amp;quot; 1&amp;quot;, &amp;quot;cell &amp;quot; + i + &amp;quot; 2&amp;quot; });&lt;br /&gt;
    }&lt;br /&gt;
    column1.pack();&lt;br /&gt;
    column2.pack();&lt;br /&gt;
    column3.pack();&lt;br /&gt;
    // create a TableCursor to navigate around the table&lt;br /&gt;
    final TableCursor cursor = new TableCursor(table, SWT.NONE);&lt;br /&gt;
    // create an editor to edit the cell when the user hits &amp;quot;ENTER&amp;quot;&lt;br /&gt;
    // while over a cell in the table&lt;br /&gt;
    final ControlEditor editor = new ControlEditor(cursor);&lt;br /&gt;
    editor.grabHorizontal = true;&lt;br /&gt;
    editor.grabVertical = true;&lt;br /&gt;
&lt;br /&gt;
    // When the user double clicks in the TableCursor, pop up a text editor so&lt;br /&gt;
    // that&lt;br /&gt;
    // they can change the text of the cell&lt;br /&gt;
    cursor.addMouseListener(new MouseAdapter() {&lt;br /&gt;
      public void mouseDown(MouseEvent e) {&lt;br /&gt;
        final Text text = new Text(cursor, SWT.NONE);&lt;br /&gt;
        TableItem row = cursor.getRow();&lt;br /&gt;
        int column = cursor.getColumn();&lt;br /&gt;
        text.setText(row.getText(column));&lt;br /&gt;
        text.addKeyListener(new KeyAdapter() {&lt;br /&gt;
          public void keyPressed(KeyEvent e) {&lt;br /&gt;
            // close the text editor and copy the data over&lt;br /&gt;
            // when the user hits &amp;quot;ENTER&amp;quot;&lt;br /&gt;
            if (e.character == SWT.CR) {&lt;br /&gt;
              TableItem row = cursor.getRow();&lt;br /&gt;
              int column = cursor.getColumn();&lt;br /&gt;
              row.setText(column, text.getText());&lt;br /&gt;
              text.dispose();&lt;br /&gt;
            }&lt;br /&gt;
            // close the text editor when the user hits &amp;quot;ESC&amp;quot;&lt;br /&gt;
            if (e.character == SWT.ESC) {&lt;br /&gt;
              text.dispose();&lt;br /&gt;
            }&lt;br /&gt;
          }&lt;br /&gt;
        });&lt;br /&gt;
        // close the text editor when the user clicks away&lt;br /&gt;
        text.addFocusListener(new FocusAdapter() {&lt;br /&gt;
          public void focusLost(FocusEvent e) {&lt;br /&gt;
            text.dispose();&lt;br /&gt;
          }&lt;br /&gt;
        });&lt;br /&gt;
        editor.setEditor(text);&lt;br /&gt;
        text.setFocus();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    // Show the TableCursor when the user releases the &amp;quot;SHIFT&amp;quot; or &amp;quot;CTRL&amp;quot; key.&lt;br /&gt;
    // This signals the end of the multiple selection task.&lt;br /&gt;
    table.addKeyListener(new KeyAdapter() {&lt;br /&gt;
      public void keyReleased(KeyEvent e) {&lt;br /&gt;
        if (e.keyCode == SWT.CONTROL &amp;amp;&amp;amp; (e.stateMask &amp;amp; SWT.SHIFT) != 0)&lt;br /&gt;
          return;&lt;br /&gt;
        if (e.keyCode == SWT.SHIFT &amp;amp;&amp;amp; (e.stateMask &amp;amp; SWT.CONTROL) != 0)&lt;br /&gt;
          return;&lt;br /&gt;
        if (e.keyCode != SWT.CONTROL &amp;amp;&amp;amp; (e.stateMask &amp;amp; SWT.CONTROL) != 0)&lt;br /&gt;
          return;&lt;br /&gt;
        if (e.keyCode != SWT.SHIFT &amp;amp;&amp;amp; (e.stateMask &amp;amp; SWT.SHIFT) != 0)&lt;br /&gt;
          return;&lt;br /&gt;
        TableItem[] selection = table.getSelection();&lt;br /&gt;
        TableItem row = (selection.length == 0) ? table.getItem(table.getTopIndex()) : selection[0];&lt;br /&gt;
        table.showItem(row);&lt;br /&gt;
        cursor.setSelection(row, 0);&lt;br /&gt;
        cursor.setVisible(true);&lt;br /&gt;
        cursor.setFocus();&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;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>