View RSS Feed

Java Swing

JTable Printing

Rate this Entry
by , 04-26-2012 at 09:47 PM (815 Views)
Simple API is provided by the JTable to print the tables. Priting of the table could easily be done by invoking JTable.print, with no arguments:
Java Code:
try {
    if (! table.print()) {
        System.err.println("User cancelled printing");
} catch (java.awt.print.PrinterException e) {
    System.err.format("Cannot print %s%n", e.getMessage());
At normal swing, print is invoked that will bring the printing dialog box up. Return value would be showing that either users printed or cancelled to do it. java.awt.print.PrinterException could be thrown by the JTable.print, that is considered to be a checked exception, this is the reason given example use try…catch.

Submit "JTable Printing" to Facebook Submit "JTable Printing" to Digg Submit "JTable Printing" to Submit "JTable Printing" to StumbleUpon Submit "JTable Printing" to Google