Reply to comment
Java Memorandom- Graphics.drawImage
Submitted by Nobu on 2010/04/23(Fri) 08:58
in
In paint(Graphics g) call back, use drawImage() to draw an image. It is crucial to specify ImageObserver parameter.
I mistakenly passed a null to the parameter, and the drawing was not done properly. It renders only when any other event forces to repaint. When the parameter was properly set, the rendering happens correctly so that the image shows up from the beginning.
public class MyPanel extends Panel
{
public void paint(Graphics g)
{
if(null != image)
{
g.drawImage(image, imageX, imageY, this);
}
}
}
