Currently I have a live active while loop running and it does what I want my only problem is closing the frame (exit the app) while the while loop is still active.
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
I tried using the if statement to terminate the loop
if (frame.getDefaultCloseOperation() == 3){
    running = false;
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
Unfortunately as soon as the app runs automatically gets set to 3 emmidiately and there for this process does not work.
How can I set running = false; by clicking on the frame to be closed.
I want to simply close the app by just clicking on X in the connour, is that possible when having a active loop running?
 
     
     
     
     
    