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

PrinterJob prints incorrect colors on Windows NT with version 1.4

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs
    • 2d
    • x86
    • windows_nt



      Name: jk109818 Date: 08/07/2002


      FULL PRODUCT VERSION :
      Microsoft<R> Windows NT(TM)
      <C> Copyright 1985-1996 Microsoft Corp.

      C:\>java -version
      java version "1.4.0"
      Java<TM> 2 Runtime Environment, Standard Edition <build 1.4.0-b92>
      Java Hotspot<TM> Client VM <build 1.4.0-b92, mixed mode>

      C;\>

      FULL OPERATING SYSTEM VERSION :Windows NT Version 4.0


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Printer is HP 895 cse
      Happens in Forte 4 or running jar file from desktop

      A DESCRIPTION OF THE PROBLEM :
      Code which prints using printer job, prints incorrect
      colors on Windows NT with an HP 895cse printer. It works
      fine on Windows XP in version 1.4, and on Windows NT with
      version 1.3. Blue prints it should, black prints as white,
      red prints as aqua and white prints as a very pale purple.



      REGRESSION. Last worked in version 1.3.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. use this code to print a JFrame in Windows NT with an HP
      895 cse printer.
      2.
      3.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I had expected this to print the same colors on the page as
      I see on the screen as it did in version 1.3 with same
      printer. (This exact code prints fine on Windows XP in
      version 1.4 with a different HP printer.)
      Wrong colors:
        red = aqua
        white = pale purple
        black = white
        grey = blue
        blue = blue (this is okay)

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      There is no error, the colors are just wrong

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      package data;

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.JOptionPane;
      import java.awt.print.*;
      import java.awt.Paint;
      import java.awt.event.*;
      import javax.swing.event.*;


      /**
       *
       * @author shea
       * @version
       */
      public class ShortGuiPrint extends Object {
       private JFrame printme;

           /** Creates new PrintGUI */
          public ShortGuiPrint(JFrame f) {
              printme = new JFrame();
              printme = f;
          
          }
          
           
      public void PrintPage(){
              try{
                     PrinterJob pjob = PrinterJob.getPrinterJob();
                     pjob.setJobName("Table");
                     pjob.setCopies(1);
                     
           
           pjob.setPrintable(new Printable(){
           public int print(Graphics pg, PageFormat pf, int pageNum){
                 pg.setColor(Color.black);
                 int frWth = printme.getWidth();
                 int frHt = printme.getHeight();
                   if (frHt < frWth){
                     pf.setOrientation(PageFormat.LANDSCAPE);}
                   else{
                     pf.setOrientation(PageFormat.PORTRAIT);}
                                     
                 double pageHt = pf.getImageableHeight() + 50;
                 double pageWth = pf.getImageableWidth() + 100;
                
                 double scale = 1;
                 
                   if (frWth/pageWth > 1 || frHt/pageHt > 1){ // either h or w >
      page size
                      if(frWth/pageWth > frHt/pageHt)
                            scale = pageWth/frWth;
                      else
                            scale = pageHt/frHt;
                              
                   }
                        if (pageNum>0)
                           return Printable.NO_SUCH_PAGE;
                 
                         Graphics2D g2 = (Graphics2D) pg;
                         g2.setColor(Color.black);
                         g2.translate(pf.getImageableX(),pf.getImageableY());
                         g2.scale(scale,scale);
                         
                         g2.translate(0f,0f);
                         g2.setClip(0,0,(int)pageWth,(int)pageHt);
                      
                         printme.paint(g2);
                         return Printable.PAGE_EXISTS;
             }
           });
       
                 if (pjob.printDialog() == false)
                       return;
                 pjob.print();
                } catch (PrinterException pe){
                    JOptionPane.showMessageDialog(printme, "PrinterError" +
      pe, "Printing Error", JOptionPane.ERROR_MESSAGE);
                }
          }
               
      }



      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      I can print blue text on a white background to have a
      legible output, but not happy with this solution
      (Review ID: 160049)
      ======================================================================

            jgodinez Jennifer Godinez (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: