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

IllegalArgException is thrown when printing 2D graphics with StreamPrintService

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 5.0
    • client-libs
    • 2d
    • tiger
    • x86
    • windows_nt
    • Verified

      I am trying to print a small rectangle to an output stream using StreamPrintService. I am calling PrinterJob.lookupStreamPrintServices() and getting a list of factories. Then I am creating a StreamPrintservice out of one of the factories and passing the FileOutputStream. I have set this print service to the PrinterJob by calling PrinterJob.setPrintService() and I have set the printable also. When I open a native print dialog by calling PrintJob.printDialog() and click 'OK' on the print dialog, a ClassCastException is thrown on Win32 platform on JDK1.5.0-b05,06. But when I execute the same application on JDK1.5.0-b08, print dialog itself does not pop up and an IllegalArgumentException is thrown. On JDK1.5.0-b04 and before, this seems to work fine. This is reproducible only with the native dialog and hence on Win32 alone.
      I tested this on Win NT and Win XP using a Xerox Docuprint N4025.

      How to reproduce:
      I have attached a sample code. Execute the sample code on the above mentioned builds and you would notice the following exceptions:

      JDK1.5.0-b08:
      java.lang.IllegalArgumentException: Invalid value for property printer or printer port
      at sun.awt.windows.WPrintDialogPeer._show(Native Method)
      at sun.awt.windows.WPrintDialogPeer.access$000(WPrintDialogPee
      at sun.awt.windows.WPrintDialogPeer$1.run(WPrintDialogPeer.jav
      at java.lang.Thread.run(Thread.java:534)

      JDK1.5.0-b05, 06:
      java.lang.ClassCastException: sun.print.PSStreamPrintService
      at sun.awt.windows.WPrinterJob.setWin32MediaAttrib(WPrinterJob.java:1591)
      at sun.awt.windows.WPrintDialogPeer._show(Native Method)
      at sun.awt.windows.WPrintDialogPeer.access$000(WPrintDialogPeer.java:14)
      at sun.awt.windows.WPrintDialogPeer$1.run(WPrintDialogPeer.java:39)
      at java.lang.Thread.run(Thread.java:534)

      The application works fine when PrintDialog is not popped up.

            jgodinez Jennifer Godinez (Inactive)
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: