JDK1.4.2p6_1 and java.awt.PrintJob
Jonathan Chen
jonc at chen.org.nz
Mon Jan 26 15:44:50 PST 2004
Hi everyone,
I'm having problems with the printing with JDK1.4.2p6_1. The attached code
used to work sometime ago (with p4?), and works under Windows as expected,
ie Prints 2 pages, with some text. With the latest patchset, I'm
missing the second page.
Am I missing something here, or did something break?
Cheers.
--
Jonathan Chen <jonc at chen.org.nz>
----------------------------------------------------------------------
Build a man a fire, and he'll be warm for a day.
Set a man on fire, and he'll be warm for the rest of his life.
-------------- next part --------------
import java.awt.*;
public class PrintTest
{
public static void
main (
String args [])
{
JobAttributes job = new JobAttributes ();
job.setDialog (JobAttributes.DialogType.COMMON);
job.setDefaultSelection (JobAttributes.DefaultSelectionType.ALL);
PageAttributes page = new PageAttributes ();
page.setOrigin (PageAttributes.OriginType.PRINTABLE);
PrintJob pj = Toolkit.
getDefaultToolkit ().
getPrintJob (
null, "Printer",
job, page);
if (pj == null)
{
System.out.println ("Quit");
System.exit (1);
}
Graphics g = pj.getGraphics ();
if (g == null)
{
System.err.println ("Null on pj.getGraphics()");
System.exit (1);
}
g.drawString ("This is a test", 0, 20);
g.dispose ();
pj.end ();
System.exit (0);
}
}
More information about the freebsd-java
mailing list