The basis of the code is to change the colors of shapes on certain "ticks", every 10 ticks whenever 'P' is pressed. The shapes should keep changing its' colors until 'P' is pressed again. I made a while loop for this yet it keeps crashing my program. Any suggestions on what I should do with my code?
ArrayList<Shapes> shapelist; //arraylist of the shapes presentprivate boolean isParty = false;private ticksElapsed = 0;public void randomColors(){ for ( int i = 0; i < shapelist.size(); i++){ shapelist.get(i).setRandomFillColor(); } refreshCanvas();}public void partyMode(){ while (true){ ticksElapsed++; if (isParty && ticksElapsed % PARTY_MODE_INTERVAL == 0){ randomColors(); } } }public void keyPressed(KeyEvent e) { printDebugText("Find Me #4!", false); //retrieves the "key code" of the last key pressed, //this is a unique number corresponding to the pressed key int keyCode = e.getKeyCode(); if (e.getKeyCode()==KeyEvent.VK_P){ if (!isParty){ isParty = !isParty; partyMode(); } else isParty = false; }}