-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_nt, windows_2000
Name: jk109818 Date: 08/19/2002
FULL PRODUCT 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)
AND
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)
FULL OPERATING SYSTEM VERSION :
Windows NT Version 4.0
A DESCRIPTION OF THE PROBLEM :
When printing a JLabel (but also JTextField) on a
black/white (laser) printer the foreground color is not
mapped as expected (at least: black->black and white->white)
but (e.g.)
Color.black -> white
Color.blue -> black (ok)
Color.red -> white
Color.green -> white
etc.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Compile and run the code
2.Press the Print button printing to a b/w printer
3.Look at the paper
EXPECTED VERSUS ACTUAL BEHAVIOR :
The expected mappings, at least black staying black.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.print.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
public class PrintTest extends JFrame{
private static Color[] colors= {Color.black, Color.blue,
Color.red, Color.green,
Color.white, Color.cyan,
Color.darkGray, Color.gray,
Color.lightGray, Color.magenta,
Color.orange,
Color.pink,
Color.yellow};
public PrintTest(){
final JPanel panel= new JPanel(new GridLayout(0, 1));
final Printable printable= new Printable() {
public int print(Graphics g, PageFormat
pageFormat, int pageIndex) {
if (pageIndex != 0)
return NO_SUCH_PAGE;
double pageHeight =
pageFormat.getImageableHeight();
double pageWidth =
pageFormat.getImageableWidth();
int w= panel.getWidth(), h=
panel.getHeight();
Graphics2D g2 = (Graphics2D)g;
g2.translate(pageFormat.getImageableX(),
pageFormat.getImageableY());
g2.setClip(0, 0, (int)(w), (int)(h));
panel.paint(g2);
return PAGE_EXISTS;
}
};
for (int i=0; i<colors.length; i++) {
Color color= colors[i];
JLabel label= new JLabel(color.toString());
label.setForeground(color);
panel.add(label);
}
getContentPane().add(panel, BorderLayout.CENTER);
JButton button= new JButton("Print");
getContentPane().add(button, BorderLayout.SOUTH);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PrinterJob
pj=PrinterJob.getPrinterJob();
pj.setPrintable(printable);
if (pj.printDialog()) {
try {
pj.print();
} catch (PrinterException e1) {
}
}
}
});
pack();
}
public static void main(String[] args) {
(new PrintTest()).show();
}
}
---------- END SOURCE ----------
(Review ID: 163340)
======================================================================
- duplicates
-
JDK-4758447 1.4 REGRESSION: Fonts won't print on HP 582C in JRE 1.4 but works in JRE 1.3.1
- Closed
-
JDK-4727902 PrinterJob prints incorrect colors on Windows NT with version 1.4
- Closed
-
JDK-4507322 REGRESSION: Transformed image copies wrong in 16 bpp on win32
- Closed
- relates to
-
JDK-6424528 Wrong mapping of color happens if one takes print of a swing component in 16 bit color depth
- Resolved
-
JDK-4941225 drawImage to a printer under Windows 2000, 16bpp messes up image
- Closed