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:
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<Double> 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<Children> c = t.getChildren(); //Gets <Children> from Root.getSubTree
Error
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: text cannot be null or empty
I believe it is saying the text str
cannot be null or empty. How can I resolve this? the str
already has text inside it when running it, so unsure why this error is occurring.