Solved

Java printing

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

Technology Partners: 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!

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.

734 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