 import java.awt.*;

 public class MainCanvasm extends Canvas 
 { 
   protected Color color = Color.blue;
   Dimension d1; 
   Image image1; 
   Graphics offscreen1; 

  public void init() 
  { 
     d1 = getSize(); 
     d1.width = 1000;
     d1.height = 450; 
  }

  public void update(Graphics g1) 
  {  
      // create the off-screen image buffer
     // if it is invoked the first time 
      if (image1 == null) 
      { image1 = createImage(d1.width, d1.height); 
         offscreen1 = image1.getGraphics(); 
      } 

      // draw the background
       offscreen1.setColor(Color.black); 
      offscreen1.fillRect(0,0,d1.width,d1.height); 
      g1.drawImage(image1, 0, 0, this); 
   }
 
   public void paint (Graphics g1) 
   { 
    update (g1); 
   }
 
 }
