About loading an image from inside the
paintComponent method: this is not recommended.
Java calls this method often according to its own needs. To demonstrate this you can include a
System.out.println statement inside the method and see what happens as you disturb the parent JFrames environment (minimize, restore, cover/uncover with other apps).
You need to load the image only once. The place to load it is in the class constructor or a method called from the constructor. Save a reference to it in class scope (member variable) and it's ready whenever you want to use it.
Here's a demo that shows how to display an image in two ways:
[ September 02, 2004: Message edited by: Craig Wood ]