php
iphone
css
python
mysql
database
android
ruby-on-rails
regex
multithreading
eclipse
silverlight
flash
json
perl
algorithm
tsql
api
jsp
postgresql
repaint
paintComponent
super.paintComponent
Also, depending on the layout manager, this component will have a preferred size of (0, 0), and therefore will not be visible.
(0, 0)
For more information, see 2D Graphics.
Edit - Note that dynamically adding a component will force you to revalidate the container and issue a repaint request so the layout manager will layout its components again and remove any visual artifacts. Also, for more information regarding images, see Working with Images.
Anyway, the simplest approach would probably be to set the image as the icon of a JLabel instance and add that to the container. There's really no need to reinvent the wheel here.
JLabel
g.drawImage(monkey, 20, 100, this);
..would most likely have fixed the problem in the original code. It was a combined problem of:
Toolkit.getImage()
ImageIO.read()
ImageObserver
JComponent
repaint()