Huge Collections of Software Manuals and Knowledgebase

GreatManuals.com
Huge Collections of Software Manuals and Knowledgebase

 
Home Contact us Request to publish your help manuals Request to remove your help manuals Buy Now
Introduction
» J2PrinterWorks
» Print Samples and Screen Shots
» Sample Programs and Sample Code
» Installing and Uninstalling
» Pageable and Flowable
Using J2PrinterWorks
» J2Printer
» J2Printer14
» J2PrinterWebStart
» J2TextPrinter
» J2TablePrinter
» J2TreePrinter
» J2ListPrinter
» J2PanelPrinter
» J2ComponentPrinter
» J2FlowPrinter
» Working with HTML
» Utility Classes
» Converting from 1.x
» Class Diagram
» Removed Methods
Support Details
» Known Problems and Bug Reporting
» Frequently Asked Questions
» Technical Support
 
Buy J2PrinterWorks Online! Buy J2PrinterWorks Online!

J2Printer14

The class J2Printer supports the original Java 2 printing model, available since JDK 1.2, which uses the native OS printing and page setup dialogs. Under the original Java 2 printing model, the end user must specify in the print dialog the printer to be used (they will get the default printer for their machine if no print dialog is used). That is, you the programmer cannot specify the printer (or discover the available printers) programmatically. Also, only a limited set of printing values can be specified programmatically, e.g., orientation, number of copies, print job name, and paper size. The primary virtue of restricting yourself to this model is that you can build and run software using the J2Printer class under JDK 1.2.x, JDK 1.3.x, JDK 1.4.x, JDK 1.5.x, or JDK 1.6.x

The JDK 1.4 release introduced a new Java 2 printing model which extends Java printing capabilities to include support for printer discovery, programmatic printer selection, cross-platform page setup and print dialogs, and a full range of programmable print request attribute sets. J2PrinterWorks provides a special subclass of J2Printer called J2Printer14 which supports these additional capabilities. The primarily limitation of using J2Printer14 is that you must use JDK 1.4 or later to build and run software that uses the J2Printer14 class . To begin fully utilizing the JDK 1.4+ capabilities, you simply change the constructor in the above code samples to: J2Printer14 printer = new J2Printer14();

Since J2Printer14 is a J2Printer subclass, all of the J2Printer methods described in the preceding sections can still be used.

Print request attribute sets

Under the JDK 1.4+ printing model, you can specify a broad range of desired print features and characteristics using a PrintRequestAttributeSet and pass these to your J2Printer14 instance to control printing using the method setPrintRequestAttributeSet. The following example shows how this is done:

J2Printer14 printer = new J2Printer14();
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(2));
aset.add(new JobName("My print job name", null));
aset.add(MediaSizeName.ISO_A4);
printer.setPrintRequestAttributeSet(aset);

See the JDK 1.4+ class PrintRequestAttributeSet for the complete list of print attributes that may be specified. The values you specify with a PrintRequestAttributeSet will be used in initializing both the page setup and print dialogs. The values may be modified or ignored by the underlying system in displaying the page setup and print dialogs depending on the capabilities of the current printer. The end user may further modify the choices presented to them in the page setup and print dialogs to arrive at the settings actually used in printing. The internal value actually used in printing (and returned by the J2Printer14 method getPrintRequestAttributeSet ) will automatically be updated to reflect these modifications.

digital photo restore compact flash recovery digital camera repair
data recovery download bulk sms best data recovery
flash card data recovery data recovery usb drive recovery

You can still use the J2Printer methods setNumberOfCopies, setPrintJobName, setPaperSize, setOrientation, setPageFormat, and the four methods for setting margins setLeftMargin, setRightMargin, setTopMargin, and setBottomMargin. The values set by these methods will update the values set by your most recent call to setPrintRequestAttributeSet to determine the values used in the page setup and print dialogs. Likewise, when you call setPrintRequestAttributeSet and specify any of the same attributes, these values will be used to update the J2Printer method values. Thus, you can use and intermix calls with either the J2Printer API or the PrintRequestAttributeSet API and the most recent versions of all the values will be used. Note, however, that attributes such as PageRanges that do not have corresponding "set" methods are not supported by Java for the native print dialogs and will only work when using the cross-platform print dialogs (this is true even if you have called setPrintDialogUsed(false))

Cross-platform dialogs

The J2Printer14 method setCrossPlatformDialogs is used to control whether the native OS page setup and print dialogs or the cross-platform page setup and print dialogs are used.

setCrossPlatformDialogs (boolean crossPlatformDialogs): Sets whether to use the cross-platform printing dialogs instead of the native printing dialogs.

Printer discovery

J2Printer14 allows you to find the list of available printers for a given print job. This is done using the following code:

J2Printer14 printer = new J2Printer14();
printer.setPrintRequestAttributeSet(yourAttributeSet);
String[] printerNames = printer.getPrinterNames();

The getPrinterNames method returns an array of printer names that can support your specified PrintRequestAttributeSet. If yourAttributeSet is null, all available printers are returned. The available printers are all those known to the user's underlying OS, whether directly connected to the user's machine or available across the network, i.e., the same list that normally appears as the printer choices in a print dialog (NOTE: as of JDK 1.4.2, Apple does not yet support printer discovery on the Macintosh, so that if any PrintRequestAttributeSet is specified, the getPrinterNames() method will return no printer names).

»

Buy J2PrinterWorks Online! Buy J2PrinterWorks Online!
Home | Contact Us | Request to publish your help manuals | Request to remove your help manuals