public void print ( Printable painter ) { printer . setPrintable ( painter ) ; if ( printer . printDialog ( printAttributes ) ) { try { printer . print ( printAttributes ) ; } catch ( PrinterException ex ) { logger . error ( "Failed to print" , ex ) ; JOptionPane . showMessageDialog ( null , ex . getMessage ( ) , "Error" , JOptionPane . ERROR_MESSAGE ) ; } } }
Prints a document that implements Printable interface .