|
J2PrinterWebStart |
|
J2PrinterWorks also supports the ability to print using Sun's Java Web Start
deployment technology and the JNLP APIs. The
capability allows the creation of special Java Web Start applications
which can be downloaded from a web site like an applet but are then
retained on the client so that thereafter they can launch and run more
like a standalone application. Java Web Start applications are
also not as restricted as applets and can do a number of things that
untrusted applets cannot do, including read and write local files and
print. Typically, Java Web Start programs will ask the user the
first time if it OK to print and whether it doesn't need to ask again,
all without the need to "sign" the program code or deal with the Java
Security Model.
J2PrinterWorks supports Java Web Start printing using a special
subclass of J2Printer called J2PrinterWebStart. The
J2PrinterWebStart printing class is instantiated and used just like the
J2Printer printing class. In particular, it can print any
Pageable, including all the J2PrinterWorks Pageable components.
For example:
J2PrinterWebStart j2pws = new
J2PrinterWebStart();
J2TextPrinter j2tp = new
J2TextPrinter(yourJTextPane);
j2pws.print(j2tp);
J2PrinterWebStart can also bring up the Java Web Start page setup
dialog and the J2PrinterWorks print preview dialog:
j2pws.showPageSetupDialog();
j2pws.showPrintPreviewDialog(new JFrame());
However, Java Web Start is not quite as general as regular Java "PrinterJob" printing, and as a consequence the J2PrinterWebStart printing class introduces a few restrictions when compared to the J2Printer printing class. In particular, Java Web Start printing does not support the following capabilities:
setPrintDialogUsed(boolean)
setNumberOfCopies(int)
setPrintJobName(String)
setPrinterJob(PrinterJob)