java.awt
public class Canvas extends Component implements Serializable, Accessible
Canvas
component provides a blank rectangular
area, which the client application can use for drawing and for
capturing events. By overriding the paint()
method,
the canvas can be used for anything from simple line drawings to
full-scale custom components.
Since: 1.0
Nested Class Summary | |
---|---|
protected class | Canvas.AccessibleAWTCanvas
This class provides accessibility support for the canvas. |
Constructor Summary | |
---|---|
Canvas()
Initializes a new instance of Canvas . | |
Canvas(GraphicsConfiguration graphicsConfiguration)
Initializes a new instance of Canvas
with the supplied graphics configuration.
|
Method Summary | |
---|---|
void | addNotify()
Creates the native peer for this object. |
void | createBufferStrategy(int numBuffers)
Creates a buffering strategy that manages how this canvas is
repainted. |
void | createBufferStrategy(int numBuffers, BufferCapabilities caps)
Creates a buffering strategy that manages how this canvas is
repainted. |
AccessibleContext | getAccessibleContext()
Gets the AccessibleContext associated with this Canvas .
|
BufferStrategy | getBufferStrategy()
Returns the buffer strategy used by the canvas.
|
void | paint(Graphics gfx)
Repaints the canvas window. |
void | update(Graphics graphics)
Updates the canvas in response to a request to
repaint() it. |
Canvas
.Canvas
with the supplied graphics configuration.
Parameters: graphicsConfiguration the graphics configuration to use for this particular canvas.
Parameters: numBuffers the number of buffers in this strategy
Throws: IllegalArgumentException if requested number of buffers is less than one IllegalStateException if this canvas is not displayable
Since: 1.4
Parameters: numBuffers the number of buffers in this strategy caps the requested buffering capabilities
Throws: AWTException if the requested capabilities are not supported IllegalArgumentException if requested number of buffers is less than one or if caps is null
Since: 1.4
Canvas
.
The context is created, if necessary.
Returns: the associated context
Returns: the buffer strategy.
Since: 1.4
Parameters: gfx the Graphics
to use for painting
repaint()
it. The canvas is cleared
with the current background colour, before paint()
is called to add the new contents. Subclasses
which override this method should either call this
method via super.update(graphics)
or re-implement
this behaviour, so as to ensure that the canvas is
clear before painting takes place.
Parameters: graphics the graphics context.