Solved

Printing

Posted on 2004-09-22
8
274 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse shortcuts 9 55
windows explorer path to command prompt 5 44
servlet example 11 40
eclipse console opening separately 2 21
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
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.

777 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