Help with controlP5 library

Using the controlP5 library, I’m having trouble.
I get this error message:

Aug 10, 2019 7:53:24 AM controlP5.ControlBroadcaster printMethodError
SEVERE: An error occured while forwarding a Controller event, please check your code at controlEvent
java.lang.reflect.InvocationTargetException

With this code:

import controlP5.*;
import processing.net.*;

ControlP5 cp5;

String textoBusqueda = "";
Client cliente;

void setup() {
  size(600, 100);
  background(51);
  cp5 = new ControlP5(this);
  cp5.addTextfield("en que pensas?")
     .setPosition(150, 30)
     .setSize(300,30)
     .setFocus(true);
   cliente = new Client(this, "127.0.0.1", 8085);

}

void draw() {
  background(0);
} 

void controlEvent(ControlEvent theEvent) {
  textoBusqueda=cp5.get(Textfield.class,"input").getText();
  if(theEvent.isAssignableFrom(Textfield.class)) {
          if(textoBusqueda != "" && key==ENTER){
              cliente.write(textoBusqueda); // codigo para envio datos al servidor
              textoBusqueda = "";
            } 
  }
}
1 Like

I’m sorry, I’ve no idea about the error you write about, but here’s another suggestion:

textoBusqueda != “”

is not the way to compare Strings. It is

!textoBusqueda.equals("")

Or

textoBusqueda.isEmpty()
1 Like

Or !"".equals(textoBusqueda), which is much safer than !textoBusqueda.equals("") and even textoBusqueda.isEmpty(); b/c it’s impervious to textoBusqueda being null. :nerd_face:

1 Like

Thanks for the advice, I’m still looking for the solution about the problem with the library