> I have been fighting for days with printing in JDK1.1.7v3 and JDK1.2.2
> without even getting the print job dialog tho show up!
> 
> I get the following stack trace using JDK1.2.2:
> Uncaught exception: java.lang.NullPointerException
>         at sun.awt.motif.UPrintDialog.<init>(UPrintDialog.java:174)
>         at sun.awt.motif.PSPrintControl$1.run(PSPrintControl.java:114)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at sun.awt.motif.PSPrintControl.<init>(PSPrintControl.java:111)
>         at sun.awt.motif.MToolkit.getPrintJob(MToolkit.java:310)
>         at PrintTest.<init>(PrintTest.java:10)
>         at PrintTest.main(PrintTest.java:18)
>         at sun.tools.agent.MainThread.runMain(Native Method)
>         at sun.tools.agent.MainThread.run(MainThread.java:49)
> 
> ...when running this program:
[...]

You ran into bug 4093775 reported to Sun's JDC DB on Nov 18, 1997.
Doesn't seem like they are very brisk fixing it... Someone suggested
to call show() before getPrintJob() to work-around the problem.
Someone else noted that it's actually addNotify() (which is called
by show) which must be called. I've tried your example with show()
and it works -- well, it nearly works... you will run into bug
4046088, reported on Apr 18, 1997, then (getFontMetrics() thowing a
NullPointerException). To fix this, someone suggested to call
g.setFont() bevor drawString(). I tried g.setFont(getFont()) and it
finally printed "Hello World!".


CU,
Stefan


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to