简体   繁体   English

如何在Java小程序中获取/使用缓冲策略?

[英]How to get / use bufferstrategy in a Java applet?

I was wondering how I would use something like a bufferstrategy in a Java Applet. 我想知道如何在Java Applet中使用诸如缓冲策略之类的方法。

I want to draw something like an image 我想画些像图像的东西

gfx.drawImage(frame, 0, 0, width, height, null);

to my applet but I am getting white flashes due to the graphics drawing to the screen not being buffered. 到我的applet,但由于未缓冲绘制到屏幕的图形,所以我出现了白色闪烁。

Any help would be greatly appreciated! 任何帮助将不胜感激!

Edit: I have a thread that is repainting this image 编辑:我有一个线程正在重绘此图像

Edit 2: The image is constantly changing so I need to repaint it each time it changes 编辑2:图像在不断变化,因此每次更改时我都需要重新粉刷

Ah, so the public void update(Graphics g) method doesn't have white flashes due to the graphics drawing to the screen not being buffered. 嗯,由于未缓冲到屏幕的图形,因此public void update(Graphics g)方法没有白色闪烁。 But the paint method does. 但是绘制方法确实可以。 Odd. 奇。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM