All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.awt.Canvas

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas

public class Canvas
extends Component
A Canvas component represents a blank rectangular area of the screen onto which the application can draw or from which the application can trap input events from the user.

An application must subclass the Canvas class in order to get useful functionality such as creating a custom component. The paint method must be overridden in order to perform custom graphics on the canvas.


Constructor Index

 o Canvas()
Constructs a new Canvas.

Method Index

 o addNotify()
Creates the peer of the canvas.
 o paint(Graphics)
This method is called to repaint this canvas.

Constructors

 o Canvas
 public Canvas()
Constructs a new Canvas.

Methods

 o addNotify
 public void addNotify()
Creates the peer of the canvas. This peer allows you to change the user interface of the canvas without changing its functionality.

Overrides:
addNotify in class Component
See Also:
createCanvas, getToolkit
 o paint
 public void paint(Graphics g)
This method is called to repaint this canvas. Most applications that subclass Canvas should override this method in order to perform some useful operation.

The paint method provided by Canvas redraws this canvas's rectangle in the background color.

The graphics context's origin (0, 0) is the top-left corner of this canvas. Its clipping region is the area of the context.

Parameters:
g - the graphics context.
Overrides:
paint in class Component
See Also:
Graphics

All Packages  Class Hierarchy  This Package  Previous  Next  Index

Submit a bug or feature