|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Canvas
public class Canvas
The 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.
Nested Class Summary | |
---|---|
protected class |
Canvas.AccessibleAWTCanvas
This class provides accessibility support for the canvas. |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
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()
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Canvas()
Canvas
.
public Canvas(GraphicsConfiguration graphicsConfiguration)
Canvas
with the supplied graphics configuration.
graphicsConfiguration
- the graphics configuration to use
for this particular canvas.Method Detail |
---|
public void addNotify()
addNotify
in class Component
Component.isDisplayable()
,
Component.removeNotify()
public void paint(Graphics gfx)
paint
in class Component
gfx
- the Graphics
to use for paintingComponent.update(Graphics)
public AccessibleContext getAccessibleContext()
Canvas
.
The context is created, if necessary.
getAccessibleContext
in interface Accessible
getAccessibleContext
in class Component
public void createBufferStrategy(int numBuffers)
numBuffers
- the number of buffers in this strategy
IllegalArgumentException
- if requested number of buffers
is less than one
IllegalStateException
- if this canvas is not displayablepublic void createBufferStrategy(int numBuffers, BufferCapabilities caps) throws AWTException
numBuffers
- the number of buffers in this strategycaps
- the requested buffering capabilities
AWTException
- if the requested capabilities are not
supported
IllegalArgumentException
- if requested number of buffers
is less than one or if caps is nullpublic BufferStrategy getBufferStrategy()
public void update(Graphics graphics)
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.
update
in class Component
graphics
- the graphics context.Component.paint(Graphics)
,
Component.repaint()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |