a) call paintComponent directly.
b) do any extensive work (like opening a file) from paintComponent. Painting can occur several times a second, and therefore also the opening. Instead, open the file before you paint, keep a reference to the image, then call repaint(). Let paintComponent draw the stored image.