I know that this has been asked many times before, but every time I visit the question thread and excecute the posed solution, it still doesn\'t work for me.
So befo
You need to create a separate image to draw all things on:
im=createImage(getWidth(), getHeight());
in init.
Then in your paint:
Graphics g2=im.getGraphics();
g2.setColor(Color.WHITE);
g2.fillRect(0,0,600,600);
and continue with all the g commands replaced with g2:
g2.setColor(Color.BLACK);
g2.fillPolygon(xpoints, ypoints, 5);
then you draw the image on g:
g.drawImage(im, 0, 0, this);
and you have an update method:
public void update(Graphics g) { paint(g); }