Printing a JTable in JAVA

I want to print a JTable which extends DefaultDableModel.
I am using JDK 1.6
The print dialog should show custom options like choosing landscape/portrair modes etc.

Who is Participating?
zzynxSoftware engineerCommented:
Since Java 1.5 the class JTable has a print() method:

public boolean print() throws PrinterException

A convenience method that displays a printing dialog, and then prints this JTable in mode PrintMode.FIT_WIDTH, with no header or footer text. A modal progress dialog, with an abort option, will be shown for the duration of printing.

     true, unless printing is cancelled by the user
     PrinterException - if an error in the print system causes the job to be aborted
See Also:
     print(JTable.PrintMode, MessageFormat, MessageFormat, boolean, PrintRequestAttributeSet, boolean),  
     getPrintable(javax.swing.JTable.PrintMode, java.text.MessageFormat, java.text.MessageFormat)

So, this is how I print the tables in my app (Jave 1.5 or higher required):


(I link it with the pressing of Ctrl+P in my table)
i think the point must be splitted.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.