I've been coding a simulation that has a JFrame
GUI for parameter input, and a separate JFrame
that runs an animation of the simulation.
I update the animation together with the simulation, so the call to repaint comes from the function runsimulation()
I have added an EXIT_ON_CLOSE
for my main GUI frame, and while the animation is running I can close the frame and it doesn't pop up again, but I want to know if it is possible to shut down the simulation thread when I close the animation frame.
Because currently when I close the frame the simulation keeps on running in the background and finishes properly, but I'd like the close event on the animation frame to be a "cancel simulation" as well.