Double buffering |
Start | Prev | Next |

Image img = null;
Graphics img_g = null;
public void init() {
img = createImage(size().width, size().height);
img_g = img.getGraphics();
img_g.setColor(Color.black);
}
public void update(Graphics g) {
paint(g);
}
public void paint(Graphics g) {
g.drawImage(img,0,0,this);
}
public boolean mouseDrag(Event e, int x, int y) {
img_g.drawLine(lastx,lasty,x,y);
repaint();
...
}