title: How to avoid org.eclipse.swt.SWTException: Invalid thread access
body: <p>I have a listener to an SWT button which starts like this:</p>
  
  <pre><code>button1.addSelectionListener(new SelectionAdapter() {
    @Override
    public void widgetSelected(SelectionEvent e) {
      Runnable runnable = new Runnable() {
        public void run() {
          String nextValue = text1.getText();
          ...
  </code></pre>
  
  <p>I need the current value of the Text field called text1 in the UI, but the last line getText() fails with </p>
  
  <p><code>org.eclipse.swt.SWTException: Invalid thread access</code></p>
  
  <p>I know about syncExec/asyncExec (my code has several) but other threads here at StackOverflow suggest you only need to use it when you want to update a field in the UI.  What is the correct way to read a UI field inside a listener?</p>