예제 #1
0
  public void update(Graphics g) {
    flags |= IS_IN_UPDATE;

    // clear and draw yourself
    g.clearRect(0, 0, width, height);
    paint(g);

    flags &= ~IS_IN_UPDATE;
  }
예제 #2
0
 void makeImage() {
   // if we have no image or if the image has changed
   if (getGraphicsConfiguration() != null && getWidth() > 0) {
     Dimension dim = c.getPreferredSize();
     // width and height must be > 0 to be able to create an image
     if (dim.height > 0) {
       img = getGraphicsConfiguration().createCompatibleImage(getWidth(), dim.height);
       c.setSize(getWidth(), dim.height);
       c.paint(img.getGraphics());
     } else {
       img = null;
     }
   }
 }