File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Printing an object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Printing an object" Watch "Printing an object" New topic
Author

Printing an object

Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
Hi all,

I am very new to the topic related to I/O operations.
I would like to know if there is any way of printing an object. At the printing stage, is it possible to allign the fields of the object?

Looking forward for guidance.

Thank you.
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
I got a little closer to the above mentioned problem.
I am able to print graphical objects on the desired location (by providing the co-ordinates). But, I am not able to allocate a location to print the object "o". Is there any way to do it?






Thanks
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8910
    
    8

Are you attempting to print an object to a printer (which is what java.awt.print is for) or are you just trying to write the object's values out to the screen (which is what System.out.println() is for)?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
Oh yea, i shouldnt have used System.out.println();
My requirement is to print an object at the printer directly.
Is there a way? If there is, please guide me.

Thanks.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8910
    
    8

There is no way to send an object to a printer directly. How would a printer know what to print? There's a chapter on the printing API in the Java Tutorial that would be a good place to start.
Vani Shastri
Ranch Hand

Joined: Aug 17, 2006
Posts: 52
Thanks for tht API. But I guess objects are printable. For eg in the above mentioned code, the object "rect" is printed. My understanding was we have to import awt.print and implement printable. I agree that the user cannot give acommand to print the object directly. That job is done by the Printable object (If I have understood it right).

PrinterJob job = PrinterJob.getPrinterJob();

job.setPrintable(new PrintObject());

Do correct me if I am wrong.
 
jQuery in Action, 2nd edition
 
subject: Printing an object