I'm creating a silly game, and the first thing I want to make is to tell you "You Lose" if the all that you control with the mouse is not inside the frame. I created a JComponent and every 20 milliseconds it is repainted (A thread does that). Inside it, I detect if the ball is inside the the frame, an if it's not, I just call a method that puts a JOptionPane that says "You Lose", and then exits the program. the problem is, since the JComponent is repainted every 20 milliseconds, loads of JOptionPane messages star to appear. I've tried making the repainting stop, but I was unsuccessful. I tried using the interrupt() method of the thread, telling it to sleep(), removing it from the ScheduledThreadPoolExecutor it was being executed by, shutting down the executor, but nothing worked. How can I make the repainting stop?
Thanks in advance.