Solved

Java printing

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
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 …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now