Loading...
Logo
Processing Forum
I am trying to pass the value of a ControlP5 Textfield out of the user-named method to get the value to a class method but i am getting this error: 

Copy code
  1. Jan 21, 2012 3:02:03 PM controlP5.ControlBroadcaster printMethodError
  2. SEVERE: An error occured while forwarding a Controller value
  3.  to a method in your program. Please check your code for any 
  4. possible errors that might occur in this method .
  5.  e.g. check for casting errors, possible nullpointers, array overflows ... .
  6. method: inputField
  7. exception:  java.lang.reflect.InvocationTargetException
and here is the code i am using:  

Copy code
  1. ControlP5 gui;
  2. gui = new ControlP5(this);
  3. String consoleText;
  4. Textfield inputField;
  5. inputField = gui.addTextfield("inputField", 0, height-26, width-1, 25);
  6. inputField.keepFocus(true);

  7. public void inputField(String textFieldInput) {
  8.   commit(textFieldInput);
  9. }

  10. public void commit(String input){
  11.       consoleText.concat(input);
  12. }
I am  creating a Textfield called inputField, then instantiating it in my gui, then all i want is to pass the confirmed text (when you type then hit 'Enter') from inputField to my method that adds it to a string so i can display it in a Textarea.

not sure what the problem is exactly, there isn't a whole lot of code there for me to screw up. I found a couple others with this same error but they were dealing with multiples in a dropdownlist. any help would be great. thanks

Replies(1)

Hi, it seems like variable consoleText is never initialized. Just set consoleText to "" when you initialize it so you can concat inside your commit function.

Copy code
  1. String consoleText = "";