Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in printing a JTable

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic