// Graphically print the component to the printer
 protected synchronized void printComponent(Component c) {
   printTarget = c;
   PrinterJob pj = PrinterJob.getPrinterJob();
   pj.setPrintable(this);
   pj.printDialog();
   try {
     pj.print();
   } catch (Exception printException) {
     printException.printStackTrace();
   }
 }
Example #2
0
 /** print the canvas scaled with factor <code>scale</code> */
 public void print(double scale) {
   printScale = scale;
   PrinterJob printJob = PrinterJob.getPrinterJob();
   printJob.setPrintable(this);
   if (printJob.printDialog()) {
     try {
       printJob.print();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
 }
Example #3
0
  public void actionPerformed(ActionEvent e) {

    PrinterJob pj = PrinterJob.getPrinterJob();

    if (pj != null && pj.printDialog()) {
      pj.setPrintable(c);
      try {
        pj.print();
      } catch (PrinterException pe) {
      } finally {
        System.err.println("PRINT RETURNED");
      }
    }
  }
 private void printPlot() {
   PrinterJob job = PrinterJob.getPrinterJob();
   PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
   // PageFormat pf = job.pageDialog(aset);
   job.setPrintable(this);
   boolean ok = job.printDialog(aset);
   if (ok) {
     try {
       job.print(aset);
     } catch (PrinterException ex) {
       // showFeedback("An error was encountered while printing." + ex);
       /* The job did not successfully complete */
     }
   }
 }
Example #5
0
  public void actionPerformed(ActionEvent ae) {

    if (ae.getSource() == b) {

      PrinterJob job = PrinterJob.getPrinterJob();
      job.setPrintable(this);
      boolean ok = job.printDialog();

      if (ok) {
        try {
          job.print();
        } catch (PrinterException pe) {
          System.out.println(pe);
          pe.printStackTrace();
        }
      }
    }

    if (ae.getSource() == back) {
      new remindersub();
      f.dispose();
    }
  }