-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.1
-
x86
-
windows_2000
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)
======================================================================
- duplicates
-
JDK-4886732 AffineTransformOp does not work properly for some of the rendering hints
- Closed