You're doing a Thread.sleep()
in the Swing main thread. This is NOT good practice. You need to use a SwingWorker
thread at best.
What's happening is that it's running the first line, hitting Thread.sleep()
.
This prevents the (main) EDT thread from doing any of the repaints (as well as preventing the next line executing).
You should use a javax.swing.Timer to setup the delayed reaction and not put sleep()
calls in the main thread.