Solved

Printing

Posted on 2004-09-22
8
275 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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 92

Expert Comment

by:objects
ID: 12164763
You need to create a class that implements Printable.
0
 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

828 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