Double buffering with awt

Is double buffering (in java) possible with awt? Currently, I know that swing should not be used with awt, so I cannot use BufferStrategy and something else (I already have code written in awt that I don't want to rewrite in swing).

If double buffering is possible with awt, do I need to write a buffer manually? Unlike swing, awt does not seem to have the same double buffering capability built in.

If I need to write the code manually, is there a good tutorial to view? Or is it simply easier / advisable for a novice programmer to use swing instead?

Sorry for the multi-step question. Thank you for your time:)

+7
java swing awt doublebuffered
source share
1 answer

It is easy to get online. Just search for "double buffer awt" and you will find many examples. You can even see an old example. I wrote myself in 1998 in Java 1.0 AWT. You just need to create an instance of your own Graphics object and draw an image, and then split that image into 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); } } 
+6
source share

All Articles