示例#1
0
 /* Cancel PrinterJob jobs that haven't yet completed. */
 public void cancel() throws PrintException {
   synchronized (this) {
     if (!printing) {
       throw new PrintException("Job is not yet submitted.");
     } else if (job != null && !printReturned) {
       job.cancel();
       notifyEvent(PrintJobEvent.JOB_CANCELED);
       return;
     } else {
       throw new PrintException("Job could not be cancelled.");
     }
   }
 }
示例#2
0
  public static PageFormat getPageFormat(PageFormat pf, Properties settings, Frame frame) {
    PageFormat npf;
    if (Utils.getAsBoolean(
        settings.getProperty("useSystemPageDialog", "false"))) // $NON-NLS-1$ //$NON-NLS-2$
    {
      PrinterJob pj = PrinterJob.getPrinterJob();
      npf = pj.pageDialog(pf == null ? new PageFormat() : pf);
      pj.cancel(); // TODO:figure out if this is needed...
    } else {
      PageSetupDialog psd = new PageSetupDialog(frame, false);
      psd.showDialog(pf);
      npf = psd.getPageFormat();
    }

    return npf;
  }
 private void cancelButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cancelButtonActionPerformed
   // the printer thread only runs a loop when creating the necessary
   // puzzles. To interrupt at this stage, thread.interrupt() must
   // be used. When the actual printing has started, the print job
   // itself must be cancelled by calling job.cancel()
   thread.interrupt();
   job.cancel();
   try {
     thread.join();
   } catch (InterruptedException ex) {
     Logger.getLogger(getClass().getName())
         .log(Level.SEVERE, "Interrupted while waiting for generation thread", ex);
   }
   setVisible(false);
 } // GEN-LAST:event_cancelButtonActionPerformed