Double Buffering with awt

后端 未结 1 1327
情深已故
情深已故 2020-12-11 04:32

Is double buffering (in java) possible with awt? Currently, I\'m aware that swing should not be used with awt, so I can\'t use BufferStrategy and whatnot (I already have som

相关标签:
1条回答
  • 2020-12-11 04:55

    This is easily answered on the web. Just search for "double buffer awt" and you'll find LOTS of examples. You can even see an old example I wrote myself in 1998 in Java 1.0 AWT. You just need to instantiate your own Graphics object and draw to an Image, then blit that image into a canvas. Here's the key bit of code in my example:

      public void paint(Graphics g) {
        if (doubleBuffer) {
          paintSky(top.gBuf);
          g.drawImage(top.buf, 0, 0, this);
        } else {
          paintSky(g);
        }
      }
    
    0 讨论(0)
提交回复
热议问题