cp5 textfield yielding ArrayIndexOutOfBoundsError

edited January 2014 in Library Questions

hello,

i have been having problems with an application i am building in regards to using cps textfields. it's not a problem i have had in the past, but seems to have changed from a random occurrence to a persistent problem. when i test the cp5 example, it occurred randomly as well, but only one or two times — i can't add as much text as i want in the textfield. when i reach the end of the textfield, i get and array out of bounds error and the sketch freezes. due to other problems i was having, i have now switched back to processing 2.0 (from 2.1 and 2.1.1), which has fixed some of the issues, but i have no idea what is causing this to happen. therefore, i have no idea where to begin to debug it. i have recreated the issue in all of the current processing applications except for 1.5 because i am using pshape and it doesn't work. here is my code:

import controlP5.*;

ControlP5 cp5;

PFont font;
ControlFont cFont;

String recordFileName = "";

void setup()
{
  size(500, 500);
  cp5 = new ControlP5(this);

  font = loadFont("SansSerif-48.vlw");
  textFont(font, 32);

  cFont = new ControlFont(font, 12);

  cp5.addTextfield("recordFileName")
  .setPosition(width/2, height/2)
  .setSize(160, 20)
  .setFont(cFont)
  .setFocus(true)
  .setColor(color(255))
  .setAutoClear(false)
  .setCaptionLabel("filename");
}

void draw()
{
  background(0);
}

Answers

  • edited January 2014

    Hi, could you post the stacktrace of the error message you are seeing? I could not reproduce the error with this wip version (2.1.5).

  • edited February 2014

    hi sojamp,

    i had a feeling it would be difficult to recreate. the problem just started, it doesn't seem normal and it doesn't happen with the example. this is what prints to the console when i exceed the length of the text box (instead of scrolling the text):

    java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 19
        at com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
        at jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:100)
        at jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:205)
        at javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
        at javax.media.opengl.Threading.invoke(Threading.java:191)
        at javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:483)
        at processing.opengl.PGL.requestDraw(PGL.java:1149)
        at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1604)
        at processing.core.PApplet.run(PApplet.java:2176)
        at java.lang.Thread.run(Thread.java:695)
    Caused by: java.lang.ArrayIndexOutOfBoundsException: 19
        at controlP5.Textfield.updateLabel(Unknown Source)
        at controlP5.Textfield.draw(Unknown Source)
        at controlP5.ControllerGroup.drawControllers(Unknown Source)
        at controlP5.ControllerGroup.draw(Unknown Source)
        at controlP5.ControlWindow.draw(Unknown Source)
        at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1159)
        at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1152)
        at processing.core.PApplet.handleMethods(PApplet.java:1346)
        at processing.core.PApplet.handleDraw(PApplet.java:2320)
        at processing.opengl.PGL$PGLListener.display(PGL.java:2601)
        at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:588)
        at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:572)
        at javax.media.opengl.awt.GLCanvas$7.run(GLCanvas.java:1054)
        at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1034)
        at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:909)
        at javax.media.opengl.awt.GLCanvas$8.run(GLCanvas.java:1065)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
        at java.awt.EventQueue.access$400(EventQueue.java:82)
        at java.awt.EventQueue$2.run(EventQueue.java:676)
        at java.awt.EventQueue$2.run(EventQueue.java:674)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    
  • ^^^ Bump. I am having the same issue when typing in characters into the textfield very fast. Wonder if a delay is just needed.

  • This is the error I get sometimes when inputing text into a textfield sometimes.Error

    Anyone know why?

Sign In or Register to comment.