repaint() tells the Swing event
thread to paint the component -- the call to paintComponent() does not happen on the thread that calls repaint(). If you want to do something after the painting is completed, then either your paint method needs to notify the thread that called repaint() somehow, or you need to schedule that activity to run on the event thread using SwingUtilities.invokeLater() or invokeAndWait(), or perhaps most simply, you can do that thing in the paintComponent() method itself.