我想直接将JTextPane
打印到打印机而不显示打印对话框并在屏幕上打印进度。为此,我在javadoc中找到了以下方法:
textPane.print(headerFormat, footerFormat, boolean showPrintDialog,
PrintService service, PrintRequestAttributeSet attributes, boolean interactive);
我不明白参数4和5.我应该为PrintService
和PrintRequestAttributeSet
传递哪些参数值?
请指导我如何使用此方法。
答案 0 :(得分:1)
作为@Hovercraft suggests,相关的API是您的朋友。参数如下:
headerFormat - the text, in MessageFormat, to be used as the header, or null for no header
footerFormat - the text, in MessageFormat, to be used as the footer, or null for no footer
showPrintDialog - true to display a print dialog, false otherwise
service - initial PrintService, or null for the default
attributes - the job attributes to be applied to the print job, or null for none
interactive - whether to print in an interactive mode
你可以从这样的东西开始来获得默认/无行为:
textPane.print(null, null, false, null, null, false);