Solved

Printing

Posted on 2004-09-22
8
273 Views
Last Modified: 2010-03-31
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
0
Comment
Question by:johnchan2000
  • 5
  • 3
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12128745
> 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
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 12128759
0
 
LVL 1

Author Comment

by:johnchan2000
ID: 12161596
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
 
LVL 92

Expert Comment

by:objects
ID: 12164763
You need to create a class that implements Printable.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:johnchan2000
ID: 12165254
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
 
LVL 92

Expert Comment

by:objects
ID: 12165264
(:
0
 
LVL 1

Author Comment

by:johnchan2000
ID: 12165561
is (: the same as :( ?? And if it is why???
0
 
LVL 92

Expert Comment

by:objects
ID: 12165573
No, just smiling in a different direction
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 81
Eclipse IDE - Cannot copy/paste from console output 8 132
ArrayIndexOutOfBoundException 9 68
factorial example 4 35
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now