双缓冲与AWT [英] Double Buffering with awt
问题描述
时的双缓冲(在Java中)可能与AWT?目前,我知道,摆不应该与AWT中使用,所以我不能使用BufferStrategy使用和诸如此类的东西(我已经有一些code写的AWT,我不想在挥杆重写)。
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 some code written in awt that I don't want to rewrite in swing).
如果双缓冲是可能的AWT,我必须手工编写的缓冲区?不像秋千,AWT似乎并不具有相同的内置的双缓冲能力。
If double buffering is possible with awt, do I have to write the buffer by hand? Unlike swing, awt doesn't seem to have the same built-in double buffering capability.
如果我必须手工编写的code,有一个很好的教程来看待?或者是它只是更容易/建议对于一个新手程序员使用摇摆呢?
If I do have to write the code by hand, is there a good tutorial to look at? Or is it just easier/advisable for a novice programmer to use swing instead?
很抱歉的多步骤的问题。感谢您的时间:)
Sorry about the multi-step question. Thanks for your time :)
推荐答案
这是很容易在网络上回答。只要搜索双缓冲AWT,你会找到的例子地段。你甚至可以看到老例子我用Java AWT 1.0我自己写于1998年。你只需要实例自己的图形对象,并绘制到图像,然后的blit该图像到画布上。这里是code在我的例子中的键位:
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);
}
}
这篇关于双缓冲与AWT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!