All painting and event handling happens on one
thread, the "Swing event thread." Until your event handler returns, repaint() calls result in paint requests being queued but not executed. You
can't run your animation loop in an event handler:
you should kick off a new thread from the handler, and run the loop in that new thread. This can be very simple to do -- i.e.,