# Help with controlP5 library

**URL:** https://discourse.processing.org/t/help-with-controlp5-library/13290
**Category:** Libraries
**Created:** [August 10, 2019, 11:16am UTC](https://discourse.processing.org/t/help-with-controlp5-library/13290 "2019-08-10T11:16:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![arielmartire](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/arielmartire/32/6061_2.png) [@arielmartire](https://discourse.processing.org/u/arielmartire)
#### Post date: [August 10, 2019, 11:16am UTC](https://discourse.processing.org/t/help-with-controlp5-library/13290/1 "2019-08-10T11:16:00Z")

</div>

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:

```auto
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 = "";
            } 
  }
}

```

---

<div class="post-metadata">

### Author: ![LuckSmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lucksmith/32/5805_2.png) [@LuckSmith](https://discourse.processing.org/u/LuckSmith)
#### Post date: [August 10, 2019, 3:14pm UTC](https://discourse.processing.org/t/help-with-controlp5-library/13290/2 "2019-08-10T15:14:54Z")

</div>

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

```auto
textoBusqueda != “”

```

is not the way to compare Strings. It is

```auto
!textoBusqueda.equals("")

```

Or

```auto
textoBusqueda.isEmpty()

```

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [August 10, 2019, 4:57pm UTC](https://discourse.processing.org/t/help-with-controlp5-library/13290/3 "2019-08-10T16:57:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![arielmartire](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/arielmartire/32/6061_2.png) [@arielmartire](https://discourse.processing.org/u/arielmartire)
#### Post date: [August 12, 2019, 4:28pm UTC](https://discourse.processing.org/t/help-with-controlp5-library/13290/4 "2019-08-12T16:28:29Z")

</div>

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