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
>
>
>