Improved Buffering (cont’d) . . .
Then, in paint(), perform a simple check on the offscreen image prior to painting:
public void paint(Graphics g) {
Graphics osG = offscreen.getGraphics();
/* paint to buffered graphics
This second approach is more efficient, but not as clear to read (at first).