As the name indicates a Canvas is a region where you can draw things such as circles, triangles, ovals or any other shape. Basically it is a graphical component that represents a region. It has got a default method which is paint() method. Canvas class can be sub classed to override this default method to define your own components as shown below in the example. 

<<<<<<< canvas.Shtml





>>>>>>> 1.2
import java.awt.*;
import java.applet.*;
public class MyCanvas extends Applet { 
  public MyCanvas() { 
  public void paint(Graphics g) { 
    g.drawString("A Canvas"15,15); 

Here is the Output:


C:\newprgrm>appletviewer MyCanvas.html



Download this example.