Use invokeAndWait() instead of invokeLater() for painting.