Solved

Printing

Posted on 2004-09-22
8
276 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android development question 2 113
how to debug htl and js pages 8 80
Bot application - advice 3 81
junit initializtion error 2 22
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

710 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