   [java] Weird 2D graphics problem
  I'm working on a physics sandbox game (not an applet) with a movable camera. I was doing the graphics the cheap and easy way, drawing the objects on the level bitmap, then clipping the bitmap based on the camera position and drawing the subimage to the (actually a JPanel with some other components surrounding it). Obviously, this didn't work very well with larger worlds, since a 5000x5000 bitmap isn't a good idea.Now, I'm trying to use a bitmap as large as the screen and position the objects based on the camera position and their location in the world. I had problems with flickering, so I started using a backbuffer. Now not only is the flickering almost as bad as before, but the program uses 90% CPU and leaks memory like a sieve, quickly using up 270 MB of RAM, while the old version used about 30 MB with an empty screen. I have no idea what's wrong, here's  the code...Main class:   while(true)   {  View.canvas.drawStuff();  if(w.play == true) w.doPhysics();  try { Thread.sleep(10);  } catch (InterruptedException ex) {  }   }Custom canvas (extends JPanel):    public void create(int width, int height)    {   backbuf = createImage(width, height);   bufg = (Graphics2D) backbuf.getGraphics();    }    public void update(Graphics g)    {   g.drawImage(backbuf, 0, 0, this);    }    public void paint(Graphics g)    {   update(g);    }    public void drawStuff()    {   Thread.yield();   //draw some stuff to the buffer   repaint();    }Thanks!   
  Problem solved, I had accidentally initialized the backbuffer image to the pixel size of the level, rather than the size of the screen. Fail!   