Clearing an ArrayList

Interesting can’t see the IndexOutOfBoundsException exception :slight_smile:
What is also interesting is you get the same exception using clear() or the loop, so use clear()

What is interesting is the java.lang.reflect.InvocationTargetException. This is caused when it can’t find the method to execute.

Looking at the rest of the stack trace I see

	at dome_004$ControlFrame.setup(dome_004.java:356)
	at processing.core.PApplet.handleDraw(PApplet.java:2404)

It seems that the PApplet’s draw() method is being called before the controlFrame setup() which probably means that the toggle switch is not been configured so the ringToggle method is not been ‘set’. Looking at the rest of the trace seems to confirm this

Caused by: java.lang.NullPointerException
	at dome_004$ControlFrame.ringToggle(dome_004.java:468)

Sorry for qll the seems and maybes I am not familiar with the inner workings of controlP5, being more used to G4P.

There is another possibility and that is because your cp5 toggle is on a cp5 control frame, effectively a second window. Again depending on controlP5 implements the ControlFrame. If it does it in a similar manner to G4P then each window has its own event handling thread so they can get out of sync.

You might try and read this discussion.

1 Like