Printing

Experts,
  It seems to me JAVA has a very weak/limited printing API/capability.  I have an application that I need to add printing capability to it.  I would like to be able to do both screen dump(graphics) and text(retrieve text from a JTextArea) printing.  I have searched the net and it seems like I might have to make every class implements printable (yikes!!!).  Is there a better way -- say a general-purpose printing class that I can send anything to it for printing(bet it a JFRame, JInternalFrame, JPanel or a simple string)?

Regards,
john
LVL 1
johnchan2000Asked:
Who is Participating?
 
objectsCommented:
> say a general-purpose printing class that I can send anything to it for printing

Thats really what a Printable instance gives you.
The print() method is passed the graphic context for the page, and you can print whatever you like to it.
0
 
johnchan2000Author Commented:
what would you need to do to format a printout?  Is there such a thing as print.setFitToPage(true)?
I have the code that does the general-purpose printing (from www.apl.jhu.edu) but it's hellish to
try to get a JPanel of size 200,300 and/or a JInternalFrame of size 800x1200 to be fitted snugly into
the page when printed.  Seems like I would need to modify the code to calculate the sizes each
and every I need to print some thing in order to get the effect I need (fit to page).

Regards,
john
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
objectsCommented:
You need to create a class that implements Printable.
0
 
johnchan2000Author Commented:
Found something at Sun's website that does exactly what I want it to do
http://java.sun.com/products/java-media/2D/forDevelopers/sdk12print.html#printing

Thanks a bunch
john
0
 
objectsCommented:
(:
0
 
johnchan2000Author Commented:
is (: the same as :( ?? And if it is why???
0
 
objectsCommented:
No, just smiling in a different direction
0
All Courses

From novice to tech pro — start learning today.