my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes How to print my table (send to printer)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to print my table (send to printer)?" Watch "How to print my table (send to printer)?" New topic
Author

How to print my table (send to printer)?

Chris Ben
Ranch Hand

Joined: Jan 15, 2001
Posts: 135
Hi,
I have a table in a scroll pane and would like to print out the contents by adding a 'print' feature in the menu bar. Can anyone tell me which class in java api will help me do the printing by the default printer?
Thanks
Chris
john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
go to : http://developer.java.sun.com/developer/onlineTraining/Programming/JDCBook/advprint.html
its a good place to start, but the example only works if all fields in the table are populated so u will need to play with the code
------------------
Chris Ben
Ranch Hand

Joined: Jan 15, 2001
Posts: 135
Hi John,
Thank you so much. Your information save me a lot of time and I only need to add two lines to make my case work.
Have a nice day
Chris
Shaz Ali
Greenhorn

Joined: Sep 08, 2001
Posts: 5
Originally posted by Chris Ben:
Hi John,
Thank you so much. Your information save me a lot of time and I only need to add two lines to make my case work.
Have a nice day
Chris

Hi
Chris can u pls write those lines for me...
because its working fine only for JTable,but if i m printing whole JPanel its giving error printing........
Chris Ben
Ranch Hand

Joined: Jan 15, 2001
Posts: 135
Sorry for responding so late. What I need to do is to print the table only, though it is in the scroll panel, I do not care about the part other than the contents of the table.
Check report.java in that website, I almost directly copy its codes for printing with my own TableModel written before.
good luck
Chris
 
 
subject: How to print my table (send to printer)?
 
Similar Threads
how to print in java !!!
how to send a text file to the printer
how to make a printer friendly page?
Printing to a Network Printer
Need to get IP Address