< prev index next >

src/java.desktop/share/classes/sun/print/RasterPrinterJob.java

Print this page




 749         }
 750     }
 751 
 752     /**
 753      * return a PageFormat corresponding to the updated attributes,
 754      * or null if the user cancelled the dialog.
 755      */
 756     @SuppressWarnings("deprecation")
 757     public PageFormat pageDialog(final PrintRequestAttributeSet attributes)
 758         throws HeadlessException {
 759         if (GraphicsEnvironment.isHeadless()) {
 760             throw new HeadlessException();
 761         }
 762 
 763         DialogTypeSelection dlg =
 764             (DialogTypeSelection)attributes.get(DialogTypeSelection.class);
 765 
 766         // Check for native, note that default dialog is COMMON.
 767         if (dlg == DialogTypeSelection.NATIVE) {
 768             PrintService pservice = getPrintService();
 769             PageFormat page = pageDialog(attributeToPageFormat(pservice,
 770                                                                attributes));







 771             updateAttributesWithPageFormat(pservice, page, attributes);
 772             return page;
 773         }
 774 
 775         final GraphicsConfiguration gc =
 776             GraphicsEnvironment.getLocalGraphicsEnvironment().
 777             getDefaultScreenDevice().getDefaultConfiguration();
 778         Rectangle bounds = gc.getBounds();
 779         int x = bounds.x+bounds.width/3;
 780         int y = bounds.y+bounds.height/3;
 781 
 782         PrintService service = java.security.AccessController.doPrivileged(
 783                                new java.security.PrivilegedAction<PrintService>() {
 784                 public PrintService run() {
 785                     PrintService service = getPrintService();
 786                     if (service == null) {
 787                         ServiceDialog.showNoPrintService(gc);
 788                         return null;
 789                     }
 790                     return service;




 749         }
 750     }
 751 
 752     /**
 753      * return a PageFormat corresponding to the updated attributes,
 754      * or null if the user cancelled the dialog.
 755      */
 756     @SuppressWarnings("deprecation")
 757     public PageFormat pageDialog(final PrintRequestAttributeSet attributes)
 758         throws HeadlessException {
 759         if (GraphicsEnvironment.isHeadless()) {
 760             throw new HeadlessException();
 761         }
 762 
 763         DialogTypeSelection dlg =
 764             (DialogTypeSelection)attributes.get(DialogTypeSelection.class);
 765 
 766         // Check for native, note that default dialog is COMMON.
 767         if (dlg == DialogTypeSelection.NATIVE) {
 768             PrintService pservice = getPrintService();
 769             PageFormat pageFrmAttrib = attributeToPageFormat(pservice, 
 770                                                              attributes);
 771             PageFormat page = pageDialog(pageFrmAttrib);
 772             
 773             // If user cancels the dialog, pageDialog() will return the original
 774             // page object and as per spec, we should return null in that case.
 775             if (page == pageFrmAttrib) {
 776                 return null;
 777             }
 778             updateAttributesWithPageFormat(pservice, page, attributes);
 779             return page;
 780         }
 781 
 782         final GraphicsConfiguration gc =
 783             GraphicsEnvironment.getLocalGraphicsEnvironment().
 784             getDefaultScreenDevice().getDefaultConfiguration();
 785         Rectangle bounds = gc.getBounds();
 786         int x = bounds.x+bounds.width/3;
 787         int y = bounds.y+bounds.height/3;
 788 
 789         PrintService service = java.security.AccessController.doPrivileged(
 790                                new java.security.PrivilegedAction<PrintService>() {
 791                 public PrintService run() {
 792                     PrintService service = getPrintService();
 793                     if (service == null) {
 794                         ServiceDialog.showNoPrintService(gc);
 795                         return null;
 796                     }
 797                     return service;


< prev index next >