The Thread.sleep(...) causes the Event Dispatch
Thread (EDT) to sleep which means the GUI can't repaint itself until the looping code has finished executing.
Don't use a loop and don't use Thread.sleep().
Instead you will want to use a Swing Timer to schedule animation. Read the section from the Swing tutorial on
How to Use Swing Timers for more information.
Or you could use a SwingWorker as described in the above link on "Concurrency in Swing". The SwingWorker executes on a separate Thread, so you could use Thread.sleep() in this case and then "publish" each result as it becomes available. Read the section on "Tasks That Have Interim Results" from the "Concurrency" link for more information and working examples.
Don't use paintImmediately(...). This bypasses normal painting procedures and indicates an improper design of your code.