Spec-Zone .ru
спецификации, руководства, описания, API
JavaTM 2 Platform
Std. Ed. v1.3.1

java.awt
Class Canvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class Canvas
extends Component
implements Accessible

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.

Since:
JDK1.0
See Also:
Serialized Form

Inner Class Summary
protected  class Canvas.AccessibleAWTCanvas
          This class implements accessibility support for the Canvas class.
 
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Canvas()
          Constructs a new Canvas.
Canvas(GraphicsConfiguration config)
          Constructs a new Canvas given a GraphicsConfiguration object.
 
Method Summary
 void addNotify()
          Creates the peer of the canvas.
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this Canvas.
 void paint(Graphics g)
          This method is called to repaint this canvas.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Canvas

public Canvas()
Constructs a new Canvas.

Canvas

public Canvas(GraphicsConfiguration config)
Constructs a new Canvas given a GraphicsConfiguration object.
Parameters:
config - a reference to a GraphicsConfiguration object.
See Also:
GraphicsConfiguration
Method Detail

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:
Toolkit.createCanvas(java.awt.Canvas), Component.getToolkit()

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.

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

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this Canvas. For canvases, the AccessibleContext takes the form of an AccessibleAWTCanvas. A new AccessibleAWTCanvas instance is created if necessary.
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class Component
Returns:
an AccessibleAWTCanvas that serves as the AccessibleContext of this Canvas

JavaTM 2 Platform
Std. Ed. v1.3.1

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.

free hit counter