Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Java printing

Posted on 1998-07-31
4
Medium Priority
?
221 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 40 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

916 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