< prev index next >

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

Print this page




 947         }
 948 
 949         if (!service.equals(newService)) {
 950             try {
 951                 setPrintService(newService);
 952             } catch (PrinterException e) {
 953                 /*
 954                  * The only time it would throw an exception is when
 955                  * newService is no longer available but we should still
 956                  * select this printer.
 957                  */
 958                 myService = newService;
 959             }
 960         }
 961         return true;
 962     }
 963 
 964    /**
 965      * Presents the user a dialog for changing properties of the
 966      * print job interactively.
 967      * @returns false if the user cancels the dialog and
 968      *          true otherwise.
 969      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 970      * returns true.
 971      * @see java.awt.GraphicsEnvironment#isHeadless
 972      */
 973     public boolean printDialog() throws HeadlessException {
 974 
 975         if (GraphicsEnvironment.isHeadless()) {
 976             throw new HeadlessException();
 977         }
 978 
 979         PrintRequestAttributeSet attributes =
 980           new HashPrintRequestAttributeSet();
 981         attributes.add(new Copies(getCopies()));
 982         attributes.add(new JobName(getJobName(), null));
 983         boolean doPrint = printDialog(attributes);
 984         if (doPrint) {
 985             JobName jobName = (JobName)attributes.get(JobName.class);
 986             if (jobName != null) {
 987                 setJobName(jobName.getValue());




 947         }
 948 
 949         if (!service.equals(newService)) {
 950             try {
 951                 setPrintService(newService);
 952             } catch (PrinterException e) {
 953                 /*
 954                  * The only time it would throw an exception is when
 955                  * newService is no longer available but we should still
 956                  * select this printer.
 957                  */
 958                 myService = newService;
 959             }
 960         }
 961         return true;
 962     }
 963 
 964    /**
 965      * Presents the user a dialog for changing properties of the
 966      * print job interactively.
 967      * @return false if the user cancels the dialog and
 968      *         true otherwise.
 969      * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 970      * returns true.
 971      * @see java.awt.GraphicsEnvironment#isHeadless
 972      */
 973     public boolean printDialog() throws HeadlessException {
 974 
 975         if (GraphicsEnvironment.isHeadless()) {
 976             throw new HeadlessException();
 977         }
 978 
 979         PrintRequestAttributeSet attributes =
 980           new HashPrintRequestAttributeSet();
 981         attributes.add(new Copies(getCopies()));
 982         attributes.add(new JobName(getJobName(), null));
 983         boolean doPrint = printDialog(attributes);
 984         if (doPrint) {
 985             JobName jobName = (JobName)attributes.get(JobName.class);
 986             if (jobName != null) {
 987                 setJobName(jobName.getValue());


< prev index next >