ListBox IndexOutOfBoundsException crash
Seems like the exact same issue as https://github.com/sojamo/controlp5/issues/3
Clicking a ListBox in a particular way causes an IndexOutOfBoundsException.
How to reproduce:
Click a listbox slightly outside its range of available items, and it will eventually cause a crash.

In this case, clicking around the red area after opening the listbox causes the crash.
Stacktrace I get in my particular case:
Exception in thread "Animation Thread" java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at controlP5.ListBox.onRelease(Unknown Source)
at controlP5.Controller.setMousePressed(Unknown Source)
at controlP5.ControllerGroup.setMousePressed(Unknown Source)
at controlP5.ControlWindow.mouseReleasedEvent(Unknown Source)
at controlP5.ControlWindow.mouseEvent(Unknown Source)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1398)
at processing.core.PApplet.handleMethods(PApplet.java:1593)
at processing.core.PApplet.handleMouseEvent(PApplet.java:2679)
at processing.core.PApplet.dequeueEvents(PApplet.java:2602)
at processing.core.PApplet.handleDraw(PApplet.java:2413)
at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1527)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)
My baindaid fix: So after a bit of looking around I found the source of the issue, and it's this line in particular inside the ListBox.java file (Line 135, inside the controlP5 source that is):
Map m = items.get( index );
...
Simply adding an if statement and wrapping the mentioned problematic line along with the code that comes after it seems to have fixed the problem, as such:
if(index < items.size()) {
Map m = items.get( index );
...
}
I'm not 100% certain about whether or not this is the optimal way to fix this problem, however as it has worked for me I figured I might aswell post it here incase someone else has this issue, until a more "proper" fix is made for this.
Same issue here.
if you add a DropdownList, then you have the same issue when, for instance, you do click on any other textBox.
oh ! fixed on 2.2.6. :) kind regards !