I made a button, when you click on, it calls a function, which has a big for loop. While the for is active, you can't click any other thing in the window. I want to make a STOP/EXIT button, when you click on, it exits the program (System.exit(0)). But while the for is active, you cant click on them, so basically it is useless.
How can I solve this problem?
Put your function with a big for loop inside a thread and kill the thread it when the button is pressed.