Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4374956

Toolkit.getPrintJob incorrectly throws HeadlessException in headless mode

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • client-libs
    • None
    • 2d
    • beta
    • sparc
    • solaris_7
    • Verified

      With this code:


         Toolkit tk = Toolkit.getDefaultToolkit();
         JobAttributes ja = new JobAttributes(); // getDialog == JobAttributes.DialogType.NONE
         PageAttributes pa = new PageAttributes();

         ja.setDestination(JobAttributes.DestinationType.FILE);
         ja.setFileName("jn-resolution");
         ja.setDialog(JobAttributes.DialogType.NONE);

         PrintJob pj = tk.getPrintJob(null, "finalize", ja, pa);

      I get the following exception

        java.awt.HeadlessException
              at sun.awt.motif.PSPrinterJob.printDialog(PSPrinterJob.java:507)
              at sun.java2d.PrintJob2D.printDialog(PrintJob2D.java:103)
              at sun.awt.motif.MToolkit.getPrintJob(MToolkit.java:364)
              at sun.awt.HeadlessToolkit.getPrintJob(HeadlessToolkit.java:341)
              at java_awt_PrintJob.do_getGraphics_1(java_awt_PrintJob.java:66) <--- tk.getPrintJob above.
              at java_awt_PrintJob.run(java_awt_PrintJob.java:300)
              at headless.bat.BATRunner.doTestForClass(BATRunner.java:34)
              at headless.bat.BATRunner.doTestCases(BATRunner.java:46)
              at test.run(test.java:6)
              at java.lang.Thread.run(Thread.java:488)

      According to the javadoc, setting DialogType.NONE will avoid the throwing of HeadlessException.

      See attached .tar file for the full test case.

      ============================

      the headless spec has been updated to indicate that PrintJob is not
      supported in that mode

      phil.race@eng 2000-11-15
      =======================

            jgodinez Jennifer Godinez (Inactive)
            dherronsunw David Herron (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: