title: stop animation in java applet at mouse click
body: <p>I have the following scenario: If I have a while block in the <code>paint()</code> method (used for example to simulate a simple animation such as rotating a polygon, done by multiple drawing and erasing the figure), is there a way to break the while block, when clicking the mouse inside the applet?</p>
  
  <p>The animation of the polygon is done without recalling the <code>paint()</code> method. Also would it be possible to do so if the while block looked something like this:</p>
  
  <pre><code>while (count&lt;n)
  {
      //code that draws the polygon rotating
      count++;
  }
  </code></pre>