That's because the LoadingPanel is never even shown at all. You set the LoadingPanel, load the resources, then set the GamePanel in the same method
. Even worse, that method is called on the EDT (Event Dispatch Thread), which controls events such as repainting
, action events, etc...
The solution would be to create a new thread that loads the resources, then notifies the EDT to set the GamePanel once it is done
EDIT: Ah you seem to believe that 'repaint()' blocks until it repaints the screen. Sadly it is not so. What it actually does is post a repaint event on the EDT queue. This means that the EDT will repaint the screen as soon as it is done with all the other tasks, such as returning from that actionPerformed method.