View RSS Feed

Java AWT

Using Print Setup Dialogs

Rate this Entry
by , 03-07-2012 at 06:09 PM (1520 Views)
Typically a user wishes to see the print dialog box and page setup. One can select a printer from the print dialog, pages to be printed may be specified and also number of copies could be set.

Name:  1.JPG
Views: 734
Size:  26.7 KB
Print Setup Dialog

A Print dialog is displayed by an application when a button of print command is pressed by user or he selects an item from print menu. In order to display this dialog

Call the printdialog method of the PrinterJob class:
Java Code:
PrinterJob pj = PrinterJob.getPrinterJob();
    if (pj.printDialog()) {
        try {pj.print();}
        catch (PrinterException exc) {
This method proves to be true when Ok is clicked by user so that to leave the dialog. Otherwise it would be considered as false. Choices of user in dialog get certain constraints that is dependent on the format as well number of pages that are being set for the PrinterJob.

Submit "Using Print Setup Dialogs" to Facebook Submit "Using Print Setup Dialogs" to Digg Submit "Using Print Setup Dialogs" to Submit "Using Print Setup Dialogs" to StumbleUpon Submit "Using Print Setup Dialogs" to Google