java.lang.Objectjava.awt.Component
java.awt.Canvas
public class Canvas
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.
| Nested Class Summary | |
|---|---|
protected class |
Canvas.AccessibleAWTCanvas
This class implements accessibility support for the Canvas class. |
| 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()
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. |
void |
createBufferStrategy(int numBuffers)
Creates a new strategy for multi-buffering on this component. |
void |
createBufferStrategy(int numBuffers,
BufferCapabilities caps)
Creates a new strategy for multi-buffering on this component with the required buffer capabilities. |
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this Canvas. |
BufferStrategy |
getBufferStrategy()
|
void |
paint(Graphics g)
Paints this canvas. |
void |
update(Graphics g)
Updates this canvas. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Canvas()
public Canvas(GraphicsConfiguration config)
config - a reference to a GraphicsConfiguration object.GraphicsConfiguration| Method Detail |
|---|
public void addNotify()
public void paint(Graphics g)
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 - the specified Graphics contextupdate(Graphics),
Component.paint(Graphics)public void update(Graphics g)
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 - the specified Graphics contextpaint(Graphics),
Component.update(Graphics)public void createBufferStrategy(int numBuffers)
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.
numBuffers - number of buffers to create, including the front buffer
IllegalArgumentException - if numBuffers is less than 1.
IllegalStateException - if the component is not displayableComponent.isDisplayable(),
getBufferStrategy()
public void createBufferStrategy(int numBuffers,
BufferCapabilities caps)
throws AWTException
Each time this method is called, the existing buffer strategy for this component is discarded.
numBuffers - number of buffers to createcaps - the required capabilities for creating the buffer strategy;
cannot be null
AWTException - if the capabilities supplied could 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 than 1, or if
caps is nullgetBufferStrategy()public BufferStrategy getBufferStrategy()
createBufferStrategy(int)public AccessibleContext getAccessibleContext()
getAccessibleContext in interface AccessiblegetAccessibleContext in class ComponentCes informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
6 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)