title: java: set page range for print dialog
body: <p>I'm just starting <a href="http://download.oracle.com/javase/tutorial/2d/printing/printable.html" rel="nofollow noreferrer">to learn how to print a window in Java/Swing</a>.
  (edit: just found <a href="http://download.oracle.com/javase/6/docs/technotes/guides/2d/spec/j2d-print.html" rel="nofollow noreferrer">the Java Printing Guide</a>) </p>
  
  <p>When I do this:</p>
  
  <pre><code>protected void doPrint() {
      PrinterJob job = PrinterJob.getPrinterJob();
      job.setPrintable(this);
      boolean ok = job.printDialog();
      if (ok) {
          try {
              job.print();
          } 
          catch (PrinterException ex) {
              ex.printStackTrace();
          } 
          finally {
  
          }
      }
  }
  </code></pre>
  
  <p>I get this printer dialog (on Windows XP):</p>
  
  <p><img src="https://i.stack.imgur.com/eC75K.png" alt="enter image description here"></p>
  
  <p>How do I change the page range so it's not 1-9999?</p>
  
  <p>edit: using <code>Pageable</code>/<code>Book</code> to set the page range (as @t_barbz helpfully points out) requires a <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/awt/print/PageFormat.html" rel="nofollow noreferrer">PageFormat</a>, in which case I have a catch-22, since I'd like the Print dialog to select that, and I don't seem to get a return value from the print dialog.</p>