List of usage examples for javax.swing JTextPane print
public boolean print(final MessageFormat headerFormat, final MessageFormat footerFormat, final boolean showPrintDialog, final PrintService service, final PrintRequestAttributeSet attributes, final boolean interactive) throws PrinterException
From source file:de.ailis.xadrian.components.ComplexEditor.java
/** * Prints the complex data/*from w w w . j a v a 2 s . c om*/ */ public void print() { // Prepare model final Map<String, Object> model = new HashMap<String, Object>(); model.put("complex", this.complex); model.put("print", true); model.put("config", Config.getInstance()); // Generate content final String content = TemplateFactory.processTemplate(template, model); // Put content into a text pane component final JTextPane printPane = new JTextPane(); printPane.setContentType("text/html"); ((HTMLDocument) printPane.getDocument()).setBase(Main.class.getResource("templates/")); printPane.setText(content); // Print the text pane try { printPane.print(null, null, true, null, Config.getInstance().getPrintAttributes(), true); } catch (final PrinterException e) { JOptionPane.showMessageDialog(null, I18N.getString("error.cantPrint"), I18N.getString("error.title"), JOptionPane.ERROR_MESSAGE); log.error("Unable to print complex: " + e, e); } }