StringIndexOutOfBoundsException?

edited March 2018 in Library Questions

Hi All--

I'm trying to troubleshoot an error I'm getting that's freezing my code. I've made a gui using controlP5 and underlying code to process text files and send characters over serial. I don't have much experience deciphering java error codes. I'm looking for a few tips on how to work through it and figure out where the problem is. Here is the error I'm getting:

java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1967)
    at controlP5.ControlFont.calculateHeight(Unknown Source)
    at controlP5.ControlFont.adjust(Unknown Source)
    at controlP5.Label$MultilineLabel.draw(Unknown Source)
    at controlP5.Label.draw(Unknown Source)
    at controlP5.ControllerGroup.draw(Unknown Source)
    at controlP5.ControllerGroup.drawControllers(Unknown Source)
    at controlP5.ControllerGroup.draw(Unknown Source)
    at controlP5.ControlWindow.draw(Unknown Source)
    at controlP5.ControlWindow.draw(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1427)
    at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1420)
    at processing.core.PApplet.handleMethods(PApplet.java:1614)
    at processing.core.PApplet.handleDraw(PApplet.java:2450)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1557)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
Tagged:

Answers

  • You need to provide an MCVE.

    Kf

  • It seems you read over the end or before beginning of your String array

    It’s caused by substring with error -1

    Something with the parameter is wrong

    Post your entire code or mcve

Sign In or Register to comment.