JDK-4987187 : POOR QUALITY/ILLEGIBLE TEXT WHEN PRINTING USING 16 BITS COLOR DEPTH
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-02-02
  • Updated: 2004-02-10
  • Resolved: 2004-02-10
Related Reports
Duplicate :  
Description

Name: wm7046			Date: 02/02/2004


1. Set the "Color Palette" option to 65536 colors.
     [ To set the "Color Pallette" option, right click on the desktop and choose "Propertie". Then from the "Display Properties" dialog, choose the "Settings" tab. The "Color Pallete" option is present in this tab ].

2. Compile and run the following program using jdk 1.4
     [ name the file as ComponentPrinterFrame.java]

import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;

//import com.sun.java.swing.*;
import javax.swing.*;

public class ComponentPrinterFrame
    extends JFrame
    implements Printable {
  public static void main(String[] args) {
    ComponentPrinterFrame cpf = new ComponentPrinterFrame();
    cpf.setVisible(true);
  }
  
  public ComponentPrinterFrame() {
    super("ComponentPrinterFrame v1.0");
    createUI();
  }
  
  protected void createUI() {
    JPanel panel = new JPanel();
    JButton printButton = new JButton("Print");
    panel.add(printButton);
    panel.add(new JList(new Object[] { "One", "Two", "Three" }));
    panel.add(new JButton("Push me"));
    panel.add(new JCheckBox("Chess", true));
    panel.add(new JComboBox(new Object[] { "Eins", "Zwei", "Drei" }));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    panel.add(new JTextField("ABCDEFGHIJKLMNOPQRST"));
    
    printButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ae) {
        PrinterJob pj = PrinterJob.getPrinterJob();
        pj.setPrintable(ComponentPrinterFrame.this);
        if (pj.printDialog()) {
          try { pj.print(); }
          catch (PrinterException pe) {
            System.out.println(pe);
          }
        }
      }
    });

    setContentPane(panel);

    setSize(400, 400);
    // Center.
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = getSize();
    int x = (screenSize.width - frameSize.width) / 2;
    int y = (screenSize.height - frameSize.height) / 2;
    setLocation(x, y);
    
    addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        dispose();
        System.exit(0);
      }
    });
  }
  
  public int print(Graphics g, PageFormat pf, int pageIndex) {
    if (pageIndex != 0) return NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D)g;
    g2.translate(pf.getImageableX(), pf.getImageableY());
    getContentPane().paint(g2);
    return PAGE_EXISTS;
  }
}

On the output panel, click on the "Print" button, so that the Panel gets printed. On the printed page we can see that text items are printed as white text on light grey background, thus  unreadable. The printer driver that I have use is "Cannon GP300-405 PS Ver 1.0".
(Incident Review ID: 233889) 
======================================================================

Comments
WORK AROUND Name: wm7046 Date: 02/02/2004 1. Use jdk1.3 , 1.2 etc. 2. Set "Color Pallette" to some other color. e.g 256 colors. ======================================================================
11-06-2004

EVALUATION I can reproduce this on 1.4.2 on XP using the exact driver cited (which is in the XP available driver list) and the HP5000 drivers too (PS and PCL). Interestingly I can't reproduce it on the Epson 870 inkjet I have. But this isn't a printing bug. Its a bug in the image code that happens to affect printing. The symptoms here are the same as 4727907 and 4733565 which is also using 16 bit colour screen and printing a swing UI as an image (a non-optimal thing to do). The latter of these is closed as a dup of 4507322 which is in turn closed as a dup of That bug was fixed in the 2D workspace on the 14th Sept 2004. I can reproduce the bug in the nightly build immediately before that fix and its gone away in the nightly immediately following. Since that was the only pertinent change its safe to conclude this is a duplicate of 4886732 and is fixed in 1.5 beta 1. ###@###.### 2004-02-10 ============================
10-02-2004