Double Buffer Applet Graphics

Go down

Double Buffer Applet Graphics

Post by Paul on Mon Dec 07, 2009 7:34 am

All you need to do this is to overload the update function of the Applet class
Code:

private Image dbImage;
private Graphics dbg;
public void update(Graphics g)
    {
        if(dbImage == null)
        {
            dbImage = createImage(width, height);
            dbg = dbImage.getGraphics();
        }
        dbg.setColor(getBackground());
        dbg.fillRect(0,0, width, height);
        dbg.setColor(getForeground());
        paint(dbg);
        g.drawImage(dbImage,0,0,this);
    }
avatar
Paul
Pickaxe

Posts : 611

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum