0% found this document useful (0 votes)
27 views

Canvas: Java SE 6

An application must subclass the canvas class in order to get useful functionality. The paint method must be overridden in order to perform custom graphics on the canvas. A page-flipping strategy is attempted first, then a blitting strategy using accelerated buffers is used.

Uploaded by

Mayur Gosai
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Canvas: Java SE 6

An application must subclass the canvas class in order to get useful functionality. The paint method must be overridden in order to perform custom graphics on the canvas. A page-flipping strategy is attempted first, then a blitting strategy using accelerated buffers is used.

Uploaded by

Mayur Gosai
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

java.awt.

Canvas

http://doc.java.sun.com/DocWeb/api/java.awt.Canvas

public class java.awt

Canvas

Show All Login

Java SE 6

Extends: Component Implements: Accessible Inner classes: Canvas.AccessibleAWTCanvas


Hide

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. 1.39 04/07/06 version JDK1.0 since

Constructors
public public Canvas() Constructs a new Canvas. Canvas(GraphicsConfiguration config) Hide Constructs a new Canvas given a GraphicsConfiguration object. a reference to a GraphicsConfiguration object. config See also java.awt.GraphicsConfiguration

Methods
public void addNotify() Hide Creates the peer of the canvas. This peer allows you to change the user interface of the canvas without changing its functionality. See also createCanvas(java.awt.Canvas), getToolkit() createBufferStrategy(int numBuffers) Hide Creates a new strategy for multi-buffering on this component. Multibuffering is useful for rendering performance. This method attempts to create the best strategy available with the number of buffers supplied. It will always create a BufferStrategy with that number of buffers. A page-flipping strategy is attempted first, then a blitting strategy using accelerated buffers. Finally, an unaccelerated blitting strategy is used. Each time this method is called, the existing buffer strategy for this

public void

1 of 3

9/25/2011 11:43 PM

java.awt.Canvas

http://doc.java.sun.com/DocWeb/api/java.awt.Canvas

component is discarded. numBuffers number of buffers to create, including the front buffer IllegalArgumentException: if numBuffers is less Throws than 1. IllegalStateException: if the component is not Throws displayable 1.4 since See also isDisplayable, getBufferStrategy public void createBufferStrategy(int numBuffers, BufferCapabilities caps) throws AWTException Hide Creates a new strategy for multi-buffering on this component with the required buffer capabilities. This is useful, for example, if only accelerated memory or page flipping is desired (as specified by the buffer capabilities). Each time this method is called, the existing buffer strategy for this component is discarded. numBuffers number of buffers to create the required capabilities for creating the buffer caps strategy; cannot be null AWTException: if the capabilities supplied could Throws not be supported or met; this may happen, for example, if there is not enough accelerated memory currently available, or if page flipping is specified but not possible. IllegalArgumentException: if numBuffers is less Throws than 1, or if caps is null 1.4 since See also getBufferStrategy public void paint(Graphics g) Hide Paints this canvas. Most applications that subclass Canvas should override this method in order to perform some useful operation (typically, custom painting of the canvas). The default operation is simply to clear the canvas. Applications that override this method need not call super.paint(g). the specified Graphics context g update(Graphics), paint(Graphics) See also public void update(Graphics g) Hide Updates this canvas. This method is called in response to a call to repaint. The canvas is

2 of 3

9/25/2011 11:43 PM

java.awt.Canvas

http://doc.java.sun.com/DocWeb/api/java.awt.Canvas

first cleared by filling it with the background color, and then completely redrawn by calling this canvas's paint method. Note: applications that override this method should either call super.update(g) or incorporate the functionality described above into their own code. the specified Graphics context g paint(Graphics), update(Graphics) See also

Properties
public getAccessibleContext() Hide AccessibleContext 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. return an AccessibleAWTCanvas that serves as the AccessibleContext of this Canvas since 1.3 public BufferStrategy getBufferStrategy()
Details
Top 10 Statistics Login Java SE 6 Copyright 1994-2011 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms

About DocWeb Bundles Export Export All About Sun Contact Privacy Terms of Use Trademarks

3 of 3

9/25/2011 11:43 PM

You might also like