title: Pause Graphics?
body: <p>So I have this JPanel Graphics code:</p>
  
  <pre><code>public void paint(Graphics g){
      super.paint(g);
  
      for(int y=0 ;y &lt; 50; y++){
          for(int x = 0; x &lt; 50; x++){
              if(m.getMaze(x, y).equals("g")){
                  g.drawImage(m.getGround(), x * 16, y * 16,null);
              }
              if(m.getMaze(x, y).equals("w")){
                  g.drawImage(m.getWall(), x * 16, y * 16,null);
              }
              if(m.getMaze(x, y).equals("S")){
                  g.drawImage(m.getStart(), x * 16, y * 16,null);
              }
              if(m.getMaze(x, y).equals("E")){
                  g.drawImage(m.getEnd(), x * 16, y * 16,null);
              }
          }
      }
  }
  </code></pre>
  
  <p>And inside the for loop (the second one) I would like to pause it for half a second, so you can see it drawing each tile. The thing is, is when I use</p>
  
  <pre><code>Thread.sleep(500);
  </code></pre>
  
  <p>After the second for loop, it just stops the whole thing forever. If I use </p>
  
  <pre><code>g.wait(500);
  </code></pre>
  
  <p>it keeps spamming</p>
  
  <pre><code>java.lang.IllegalMonitorStateException
  </code></pre>
  
  <p>in the console. And yes, it is surrounded with try/catch. How can I pause this?</p>