0

So I have read in multiple places that you should not draw directly onto the JFrame. Could someone please be a bit more specific on how to do this. So if I have a class like this. My objective is to minimize flashing and take advantage of the double buffering.

    public class GameFrame extends JFrame{
    public GameFrame(){
    super("FOOBAR");
    this.setSize(480,480);
    this.repaint();
    }
    public static void main(String[] a){
    //what is a better way of doing this
    GameFrame g=new GameFrame();
    while(true){
    g.repaint();
    }
    }
    public void paint(Graphics g){
    //I am not supposed to this
    g.clearRect(0,0,480,480);
    /**implementation not shown*/
    }
    }

0 Answers0