Solved

Java printing

Posted on 1998-07-31
4
219 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

632 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