Methods Summary |
---|
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.
synchronized (getTreeLock()) {
if (peer == null)
peer = getToolkit().createCanvas(this);
super.addNotify();
}
|
java.lang.String | constructComponentName()Construct a name for this component. Called by getName() when the
name is null.
synchronized (getClass()) {
return base + nameCounter++;
}
|
public void | createBufferStrategy(int numBuffers)Creates a new strategy for multi-buffering on this component.
Multi-buffering 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 component is discarded.
super.createBufferStrategy(numBuffers);
|
public void | createBufferStrategy(int numBuffers, java.awt.BufferCapabilities caps)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.
super.createBufferStrategy(numBuffers, caps);
|
public javax.accessibility.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.
if (accessibleContext == null) {
accessibleContext = new AccessibleAWTCanvas();
}
return accessibleContext;
|
public java.awt.image.BufferStrategy | getBufferStrategy()
return super.getBufferStrategy();
|
public void | paint(java.awt.Graphics g)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).
g.clearRect(0, 0, width, height);
|
boolean | postsOldMouseEvents()
return true;
|
public void | update(java.awt.Graphics g)Updates this canvas.
This method is called in response to a call to repaint .
The canvas is 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.
g.clearRect(0, 0, width, height);
paint(g);
|