I'm writing a JApplet right now, and whenever I call super.paint(), the applet flickers.
I am using double buffering (drawing to an image, and then rendering that image), but I think super.paint() is clearing the screen or something, defeating my double buffer.
I know I'm supposed to use paintComponents(), but for some reason, when I call "currentScreen.Draw(g)," it won't show the screen's draw.
Can anyone help me with this?
public void paint(Graphics g)
{
super.paint(g);//Remove this and it works, but the JApplet background color will be gone, and everything will be white.
currentScreen.Draw(g);
}
Screen Draw Method
public void Draw(Graphics g)
{
if(buffer != null)
g.drawImage(buffer, 150, 0, null);
//g.drawString(drawstring, x, y);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…