title: SWT Table checking box by selecting row or checking the box
body: <p>I want to create table of elements with checkboxes in which one could change the state of checkbox by: 1) Clicking on checkbox, 2) Clicking on row. <strong>Unfailingly and fastly.</strong></p>
  
  <p>I've tried:</p>
  
  <pre><code>import org.eclipse.swt.SWT;
  import org.eclipse.swt.widgets.*;
  
  public class Example {
  
      public static void main(String[] args) {
          Display display = new Display();
          Shell shell = new Shell(display);
          shell.setSize(280, 300);
          shell.setText("FooTable");
  
          Table table = new Table(shell, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL| SWT.H_SCROLL);
  
          String[] titles = { "Column" };
  
          for (int loopIndex = 0; loopIndex &lt; titles.length; loopIndex++) {
              TableColumn column = new TableColumn(table, SWT.NULL);
              column.setText(titles[loopIndex]);
          }
  
          for (int loopIndex = 0; loopIndex &lt; 5; loopIndex++) {
              TableItem item = new TableItem(table, SWT.NULL);
              item.setText("Item " + loopIndex);
          }
  
          for (int loopIndex = 0; loopIndex &lt; titles.length; loopIndex++) {
              table.getColumn(loopIndex).pack();
          }
  
          table.setBounds(25, 25, 220, 200);
  
          table.addListener(SWT.Selection, new Listener() {
              public void handleEvent(Event event) {
                  if (event.detail == SWT.CHECK) {
                      System.out.println("You checked " + event.item);
                  } 
                  else {
                      System.out.println("You selected " + event.item);
                      TableItem ti  = (TableItem)event.item;
                      ti.setChecked(!ti.getChecked());
                  }
              }
          });
  
          shell.open();
          while (!shell.isDisposed()) {
              if (!display.readAndDispatch())
                      display.sleep();
          }
          display.dispose();
       }
  }
  </code></pre>
  
  <p>But with this I've got at least 2 problems:</p>
  
  <p>1) When a row is selected and I click on checbox, the two listeners will at the same time change the state of checkbox, so in the end there is no effect (bad).</p>
  
  <p>2) When I double-click on a row, there again won't be any effect (bad), but when I double-click on checkbox (while row is not selected) I can clearly see checkbox changing it's state twice (good).</p>
  
  <p>So how can I fix this or achieve it in another way?</p>
  
  <p><strong>Edit</strong>
  I solved my problem by using multiple buttons instead of table, in this way</p>
  
  <pre><code>Button b = new Button(this, SWT.CHECK | SWT.WRAP);
  b.setText("item");
  </code></pre>
  
  <p>But through it all, question remains open.</p>