1 7 package java.awt; 8 9 import java.awt.image.BufferStrategy ; 10 import java.awt.peer.CanvasPeer; 11 import javax.accessibility.*; 12 13 27 public class Canvas extends Component implements Accessible { 28 29 private static final String base = "canvas"; 30 private static int nameCounter = 0; 31 32 35 private static final long serialVersionUID = -2284879212465893870L; 36 37 40 public Canvas() { 41 } 42 43 50 public Canvas(GraphicsConfiguration config) { 51 this(); 52 graphicsConfig = config; 53 } 54 55 59 String constructComponentName() { 60 synchronized (getClass()) { 61 return base + nameCounter++; 62 } 63 } 64 65 71 public void addNotify() { 72 synchronized (getTreeLock()) { 73 if (peer == null) 74 peer = getToolkit().createCanvas(this); 75 super.addNotify(); 76 } 77 } 78 79 93 public void paint(Graphics g) { 94 g.clearRect(0, 0, width, height); 95 } 96 97 112 public void update(Graphics g) { 113 g.clearRect(0, 0, width, height); 114 paint(g); 115 } 116 117 boolean postsOldMouseEvents() { 118 return true; 119 } 120 121 140 public void createBufferStrategy(int numBuffers) { 141 super.createBufferStrategy(numBuffers); 142 } 143 144 164 public void createBufferStrategy(int numBuffers, 165 BufferCapabilities caps) throws AWTException { 166 super.createBufferStrategy(numBuffers, caps); 167 } 168 169 174 public BufferStrategy getBufferStrategy() { 175 return super.getBufferStrategy(); 176 } 177 178 182 183 192 public AccessibleContext getAccessibleContext() { 193 if (accessibleContext == null) { 194 accessibleContext = new AccessibleAWTCanvas(); 195 } 196 return accessibleContext; 197 } 198 199 204 protected class AccessibleAWTCanvas extends AccessibleAWTComponent 205 { 206 private static final long serialVersionUID = -6325592262103146699L; 207 208 215 public AccessibleRole getAccessibleRole() { 216 return AccessibleRole.CANVAS; 217 } 218 219 } } 221 | Popular Tags |