NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: printing

Hello,
I have copied Curtis' code and my applet shows print dialog. However, when I
say print it, it prints nothing.
Then I copied Mathias's code and it doesn;t compile it. It gives some errors
since public void run method defined in a if command. I need more help.
Thanks,

----- Original Message -----
From: "Mathias Stümpert" <atzes@xxxxxx>
To: "'Curtis Rueden'" <curtis@xxxxxxxxxxxxx>; "'Yakup Bayram'"
<ybayram@xxxxxxxx>
Sent: Tuesday, January 29, 2002 12:31 AM
Subject: AW: printing


> Hi Curtis and Yakup,
>
> > import java.awt.print.*;
> > ...
> > DisplayImpl display = ...;
> > PrinterJob printJob = PrinterJob.getPrinterJob();
> > Printable p = display.getPrintable();
> > printJob.setPrintable(p);
> > if (printJob.printDialog()) printJob.print();
>
> That's working, but only if the printJob.print() is not called from an
> Event-Thread. In this case you have to enclose the printJob.print() in a
> new Thread:
>
> If (printJob.printDialog()) {
>   Runnable printer = new Runnable() {
>     public void run() {
>       try {
>         printJob.print();
>       } catch (Exception exc)
>         exc.printStackTrace();
>       }
>     }
>   }
>   Thread printerThread = new Thread(printer);
>   printerThread.start();
> }
>
> That is because print() is calling the getImage()-method of DisplayImpl.
>
> Cheers, Mathias
>
>
>





  • 2002 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: