File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Problem in printing a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem in printing a JTable" Watch "Problem in printing a JTable" New topic
Author

Problem in printing a JTable

aminur rashid
Ranch Hand

Joined: Sep 21, 2001
Posts: 79
Hi,
I have a JDialog.In that dialog i have a JPanel in whcih I have added a JLabel and a JTable(JTable is being added to the scroll pane and in turn scroll pane is added to panel)
Now I have a button called print in the action event of which I am printing the JPanel(Containg the label and sroll pane wih JTable).
The printing is working fine.But the problem is that when the rows of JTable is more than sp that to see the all rows of JTable user has to scroll the scroll bar and see the rows.In that case when i say print,only those rows of the table is pritned that is visble.The rest rows that is not visible to user(I mean for which user scrolls the scroll bar)is not printed.Can any one help me out how to print the all rows of JTable.
Morever can I restrict user to print only in LANDSCAPE.


Regards<br />Aminur
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Shure, if you print the content of your JPanel, then only the visible part is printed. If you want to print the whole JTable, you need to print only the JTable. The problem is, if you do it in that way, only one page is printed out and if your table is larger, then not all of the rows will be visible on your paper. So you have to calculate, how many sheets of paper you will need for a complete printout and you have to print every printable rectangle. But as far as I know, there are already some classes available, which are doing that. Here is one example: JTable Printing
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in printing a JTable