Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Nothing happens when using java.awt.print on Mac OSX.

Thread Tools

Nothing happens when using java.awt.print on Mac OSX.

Aubrey Jones
Posts: n/a
I'm attempting to print a custom-made Swing component using the
java.awt.print protocol. It works perfectly on Linux and Windows, but
totally fails on Mac OSX. I googled, and found that Apple hasn't
implemented javax.print. But, I'm not using it, unless it's hidden
somewhere in the support classes for awt.print.

Anyway, the symptoms: neither printing nor print previews work; the
printer apparently comes out of sleep mode, but doesn't even print so
much as a blank piece of paper. Also, from tracing, I know that my
component's print() gets called.

I'm at my wit's end currently, going generally nuts over this. I'm
including my print code at the bottom. The first method handles the
printing, the second is my Printable.print() implementation (without
graphics code).

Any help would be most appreciated.


* Does printing.
* */
public void printBodyImage(){
curSession.clientName = clientField.getText();
curSession.investigatorName = investigatorField.getText();
PrinterJob printJob = PrinterJob.getPrinterJob();


if (printJob.printDialog()){
try {
printJob.setPrintable(sessionPanel, printJob.defaultPage());
} catch (PrinterException pe) {


* Prints this object.
* */
public int print(Graphics g, PageFormat pageFormat, int pageIndex){
if (pageIndex > 0) {
Graphics2D g2d = (Graphics2D)g;

g2d.translate(pageFormat.getImageableX(), (pageFormat.getImageableY()
+ 72));
//These are the functions that do the actual rendering.
//They work fine on Windows and *nix, so I don't think they're
a prob.
pageFormat.getImageableHeight() - 72);
this.drawPrint(g2d, (int) pageFormat.getImageableWidth(), (int)
pageFormat.getImageableHeight() - 72);

return (PAGE_EXISTS);
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
What happens when type conversion between signed and unsigned happens? NM C++ 6 09-20-2006 05:39 PM
Nothing happens when I click a button =?Utf-8?B?bWF4ZmxvZGVu?= ASP .Net 14 02-06-2006 09:35 PM
listbox click - nothing happens? Steve ASP .Net 6 08-20-2004 06:36 AM
Re: No Error and nothing happens! John Saunders ASP .Net 1 06-30-2004 05:50 PM
Win XP Start Menu Problems...nothing happens when clicking "All Programs" and... Ian Roberts Computer Support 1 11-17-2003 01:13 PM