Receiving error but cannot debug: ArrayIndexOutOfBoundsException

You haven‘t comment on that.

What is your problem? That the changed image appears only during you hold the key?

Then you need to implement a boolean variable which you had and named a.

Did you delete it?

before setup boolean screen1bool=false;

Then on keyPressed toggle this variable as I have shown

Then outside keyPressed

if(screen1bool) {

}

1 Like