title: How to solve - java.lang.IllegalArgumentException: text cannot be null or empty
body: <p>I am trying to declare variables at the top of the class so I don't have to declare them constantly when using them. I have done so no error comes up until I want to run the program. My code is below:</p>
  
  <pre><code>public class UI extends javax.swing.JFrame {
  
  /**
   * Creates new form UI
   */
  public UI() {    
      initComponents();
      this.service.setUsernameAndPassword("9a1d5de6-7c2b-427d-a574-d6fe097c86b9", "ztil6GSHwd34");  
      this.str = txtInput.getText();
  
  
  }
  String str;
  PersonalityInsights service = new PersonalityInsights();
   ArrayList&lt;Double&gt; percentagesList = new ArrayList();        
   Profile profile = service.getProfile(str).execute();
   Gson gson = new Gson();  
   Root C = gson.fromJson(profile.toString(), Root.class);
   Root.SubTree t = C.getSubTree(); //Gets subtree from root    
   ArrayList&lt;Children&gt; c = t.getChildren(); //Gets &lt;Children&gt; from Root.getSubTree
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: text cannot be null or empty
  </code></pre>
  
  <p>I believe it is saying the text <code>str</code> cannot be null or empty. How can I resolve this? the <code>str</code> already has text inside it when running it, so unsure why this error is occurring. </p>