title: Java swt IllegalArgumentException: Argument cannot be null
body: <p>I'm trying to write a simple GUI for another program. Using Eclipse and the plugin 'WindowBuilder' for that. This is what I got so far:</p>
  <pre><code>import org.eclipse.swt.widgets.Button;
  import org.eclipse.swt.widgets.Display;
  import org.eclipse.swt.widgets.Event;
  import org.eclipse.swt.widgets.Shell;
  import org.eclipse.swt.widgets.Text;
  import org.eclipse.wb.swt.SWTResourceManager;
  import org.eclipse.swt.widgets.Label;
  import org.eclipse.swt.widgets.Listener;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.custom.StyledText;
  
  public class LightGUI {
  
    protected Shell shell;
    private Text lichterEingabe;
    private Text befehleEingabe;
    private Text ipEingabe;
    private Text portEingabe;
  
   /**
    * Launch the application.
    * @param args
    */        
    
  public static void main(String[] args) {
      try {
          LightGUI window = new LightGUI();
  //PROBLEM APPARENTLY HERE: 
          window.open();
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  /**
   * Open the window.
   */
  public void open() {
      Display display = Display.getDefault();
      createContents();
      shell.open();
      shell.layout();
      while (!shell.isDisposed()) {
  //...OR HERE:
          if (!display.readAndDispatch()) {
                  display.sleep();
          }   
      }
  }
  
  /**
   * Create contents of the window.
   */
  protected void createContents() {
      shell = new Shell();
      shell.setBackground(SWTResourceManager.getColor(230, 230, 250));
      shell.setSize(701, 513);
      shell.setText(&quot;SWT Application&quot;);
      
      Label lichter = new Label(shell, SWT.NONE);
      lichter.setBackground(SWTResourceManager.getColor(230, 230, 250));
      lichter.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 11, SWT.NORMAL));
      lichter.setBounds(70, 71, 76, 21);
      lichter.setText(&quot;Lichter:&quot;);
      
      Label befehle = new Label(shell, SWT.NONE);
      befehle.setBackground(SWTResourceManager.getColor(230, 230, 250));
      befehle.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 11, SWT.NORMAL));
      befehle.setBounds(70, 130, 76, 22);
      befehle.setText(&quot;Befehle:&quot;);
      
      Label ip = new Label(shell, SWT.NONE);
      ip.setBackground(SWTResourceManager.getColor(230, 230, 250));
      ip.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 11, SWT.NORMAL));
      ip.setBounds(350, 71, 76, 21);
      ip.setText(&quot;IP:&quot;);
      
      Label port = new Label(shell, SWT.NONE);
      port.setBackground(SWTResourceManager.getColor(230, 230, 250));
      port.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 11, SWT.NORMAL));
      port.setBounds(350, 130, 76, 22);
      port.setText(&quot;Port:&quot;);
      
      lichterEingabe = new Text(shell, SWT.BORDER);
      lichterEingabe.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 11, SWT.NORMAL));
      lichterEingabe.setBounds(177, 71, 88, 28);
      
      befehleEingabe = new Text(shell, SWT.BORDER);
      befehleEingabe.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 11, SWT.NORMAL));
      befehleEingabe.setBounds(177, 124, 88, 28);
      
      ipEingabe = new Text(shell, SWT.BORDER);
      ipEingabe.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 11, SWT.NORMAL));
      ipEingabe.setBounds(456, 71, 88, 28);
      
      portEingabe = new Text(shell, SWT.BORDER);
      portEingabe.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 11, SWT.NORMAL));
      portEingabe.setBounds(455, 124, 89, 28);
      
      Button btnNewButton = new Button(shell, SWT.NONE);
      btnNewButton.setForeground(SWTResourceManager.getColor(138, 43, 226));
      btnNewButton.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 14, SWT.BOLD));
      btnNewButton.setBounds(417, 239, 120, 49);
      btnNewButton.setText(&quot;OK!&quot;);
      
      Label rueckmeldung = new Label(shell, SWT.NONE);
      rueckmeldung.setBackground(SWTResourceManager.getColor(230, 230, 250));
      rueckmeldung.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 13, SWT.NORMAL));
      rueckmeldung.setBounds(70, 319, 134, 28);
      rueckmeldung.setText(&quot;Rueckmeldung:&quot;);
      
      StyledText styledText = new StyledText(shell, SWT.BORDER);
      styledText.setFont(SWTResourceManager.getFont(&quot;Segoe UI&quot;, 10, SWT.NORMAL));
      styledText.setEditable(false);
      styledText.setBounds(70, 353, 340, 96);
      
      
      btnNewButton.addListener(SWT.Selection, new Listener() {
            public void handleEvent(Event e) {
                switch (e.type) {
                case SWT.Selection:
                  rueckmeldung.setText(null);
                  if(lichterEingabe.getText()!=null &amp;&amp; befehleEingabe.getText()!=null &amp;&amp; ipEingabe.getText()!=null &amp;&amp; portEingabe.getText()!=null){
                      new Steuerung(Integer.parseInt(lichterEingabe.getText()), Integer.parseInt(befehleEingabe.getText()));
                  }
                  break;
                }
              }
            });
  
  
      }
  }
  </code></pre>
  <p>The window is visible and all after launching. This is the result of my code:</p>
  <p><a href="https://i.stack.imgur.com/HNGKi.png" rel="nofollow noreferrer">Small window</a></p>
  <p>One is meant to write numbers into the four textfields (the fifth, bigger one  is for the sole purpose of displaying error messages). After filling all of them, the button OK has to be clicked. Based on that, some calculations will happen in the background (calculations which won't be relevant until this works).</p>
  <p>However, what happens instead is the following:
  My window automatically disappears as soon as I've clicked the button.
  And Eclipse console shows the following error message:</p>
  <pre><code>java.lang.IllegalArgumentException: Argument cannot be null
  at org.eclipse.swt.SWT.error(SWT.java:4514)
  at org.eclipse.swt.SWT.error(SWT.java:4448)
  at org.eclipse.swt.SWT.error(SWT.java:4419)
  at org.eclipse.swt.widgets.Widget.error(Widget.java:482)
  at org.eclipse.swt.widgets.Label.setText(Label.java:403)
  at LightGUI$1.handleEvent(LightGUI.java:126)
  at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
  at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
  at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
  at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4236)
  at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3824)
  at LightGUI.open(LightGUI.java:49)
  at LightGUI.main(LightGUI.java:34)
  </code></pre>
  <p>Can anyone see something I don't? Why is this happening? There shouldn't be any changes visible, yet the program seems to think that 'window.open();' or display.readAndDispatch() return null for some reason?</p>
  <p>A hint as to what exactly is the problem would be appreciated because I don't even have the faintest idea.</p>