Solved

Java printing

Posted on 1998-07-31
4
217 Views
Last Modified: 2010-05-18
I have an application which uses all swing components (JFrame , JScrollPane, JPanel etc). I have laid many panels in my JFrame which are enclosed in a JScrollPane. I am also displaying some graphics in the viewable area. I need to print the whole set without any loss of data, like even when I reduce the size of the application. I shud be able to print the entire contents (even the non viewable part which needs the scrolling). One component is JTable which may have data half hidden, I need to get the entire row set printed. What shud I do?
0
Comment
Question by:nraghu
[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
  • 2
4 Comments
 
LVL 2

Expert Comment

by:threshold
ID: 1229585
You should create a invisible Frame(or Container) to include your components that you want to print.
If your data is very large, you should get the page size from PringJob and divide the data into several pages.
Then, Open the PrintJob to print the invisible frame.
Of cause, the Frame and the JScrollPane should be big enough to display the whole data(or sub-elements).

Maybe, you can display the invisible Frame for "preview".
0
 

Author Comment

by:nraghu
ID: 1229586
I need to handle the way MFC does. Already all my components are in a container. Jpanel.
So why shud I need an invisible frame. Does that mean that my JScrollpane shud be expanded to the maximum size. Does that mean my printing capabilities are limited
0
 
LVL 3

Expert Comment

by:mjenkins
ID: 1229587
Yes and Yes. Java isn't MFC.
0
 
LVL 2

Accepted Solution

by:
threshold earned 20 total points
ID: 1229588
In Java, The Printing is WYSWYG.
You create a component and print it, then you will see the component on printing.
If your component is showing a part of data, you will see the part of data in the sheet.

So, you should get the size/resolution of sheet from the PrintJob, and create a frame as large as the sheet. ,
then divide your data into several pages, and put the data of first page into the frame, then call the printAll() method of the frame.
Then, put the next page into the frame... and so on.

Of cause, the printed frame will be very large (depends on the size/resolution of your print sheet), so it should be invisible.

I know the capabilities of Java Printing is very poor, it can't divide your document into several pages automatically.
But it's very flexible, you can create any shema of document printing as your purpose.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 60
hibernate example issues from command prompt 10 66
mysql jsp example issue 32 75
Why is enum singleton a better approach than static factory 3 52
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
This video teaches viewers about errors in exception handling.

726 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