title: jframe flash when updating graphics
body: <p>At below, its my code to make a renewable graphics shows life game itself.</p>
  
  <pre><code>public paint(Graphics g)
  {
       g.setClip();//Set              
       g.setColor(Color.BLACK);
  
       Processing.....
  
       while(true)
       {
            g.clearRect();//Clear
  
            g.drawLine(); //Draw;
  
            Calling SwingWorking to prepare next statement
       }
  }
  </code></pre>
  
  <p>seems it's stupid to do like this way because when running it, the frame keep flashing and laggy.
  I try to use <code>Thread.sleep()</code>, but it just slow down the frequency of flash.</p>
  
  <p>So, my problem is how to make it well and avoid flashing.
  The parts of code that I don't put on are all about data processing for instance variables, if you need it,please notice me, much appreciate for help.</p>
  
  <hr>
  
  <p>Thanks, @MadProgrammer</p>
  
  <p>Here is what I got,
  first, the flash is because when program calling repaint() and paint(), it cost too much time to make animation smoothly, in this case is clearRect() and drawLine().</p>
  
  <p>I'll use double buffered to solve it.</p>
  
  <hr>
  
  <p>Update,</p>
  
  <p>Thanks guys, I read those examples. I just use a frame without any buffer method to show graphics before, what a mistake. I used bufferStrategy to solve it. </p>