title: Why does the java Printable's print method get called multiple times with the same page number?
body: <p>From <a href="http://java.sun.com/j2se/1.4.2/docs/guide/2d/spec/j2d-print.html" rel="noreferrer">sun's documentation</a> </p>
  
  <p>"The printing system might request that a page be rendered multiple times before moving to the next page."</p>
  
  <p>The examples always show something like this:</p>
  
  <pre><code>Printable print(Graphics g, PageFormat pageFormat, int page) {
      if (page == 0)
        do...
      else if(page == blah...)
  }
  </code></pre>
  
  <p>If you follow this pattern your code typically works fine because it is explicit based on the page number. Not following this pattern caused me great pain until I realized it was getting called multiple times with the same page number and started to cache the pages. </p>
  
  <p>Why does the java Printable's print method get called multiple times with the same page number?</p>