From sun's documentation
"The printing system might request that a page be rendered multiple times before moving to the next page."
The examples always show something like this:
Printable print(Graphics g, PageFormat pageFormat, int page) {
if (page == 0)
do...
else if(page == blah...)
}
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.
Why does the java Printable's print method get called multiple times with the same page number?