Mechanics of Double-Buffering
Now, we can modify our paint method.
First, let’s make sure we create the off-screen drawing area upon startup:
public void paint (Graphics g){
// is this the first time we are painting?
(curD.width, curD.height);
osG = osImg.getGraphics();