Is it possible to print the Swing component without the Print dialog box?

I would like to print the Swing component (Table Component) without user intervention so that the print dialog does not display.

Is it possible?

+4
source share
1 answer

I suggest reading a Printing tutorial,

MessageFormat header = new MessageFormat(" Whatever"); MessageFormat footer = new MessageFormat(" Page {0,number,integer} Whatever"); try { PrintRequestAttributeSet set = new HashPrintRequestAttributeSet(); set.add(OrientationRequested.LANDSCAPE); myTable.print(JTable.PrintMode.FIT_WIDTH, header, footer, false, set, false); JOptionPane.showMessageDialog(null, "\n" + "JTable was Successfully " + "\n" + "Printed on your Default Printer"); } catch (java.awt.print.PrinterException e) { JOptionPane.showMessageDialog(null, "\n" + "Error from Printer Job " + "\n" + e); } 
+4
source

Source: https://habr.com/ru/post/1388568/


All Articles