本文整理匯總了Java中javax.print.DocPrintJob.addPrintJobListener方法的典型用法代碼示例。如果您正苦於以下問題:Java DocPrintJob.addPrintJobListener方法的具體用法?Java DocPrintJob.addPrintJobListener怎麽用?Java DocPrintJob.addPrintJobListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.print.DocPrintJob
的用法示例。
在下文中一共展示了DocPrintJob.addPrintJobListener方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import javax.print.DocPrintJob; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
GraphicsEnvironment.getLocalGraphicsEnvironment();
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();
StreamPrintServiceFactory[] factories =
StreamPrintServiceFactory.
lookupStreamPrintServiceFactories(flavor, mime);
if (factories.length == 0) {
System.out.println("No print service found.");
return;
}
FileOutputStream output = new FileOutputStream("out.ps");
StreamPrintService service = factories[0].getPrintService(output);
SimpleDoc doc =
new SimpleDoc(new PrintSEUmlauts(),
DocFlavor.SERVICE_FORMATTED.PRINTABLE,
new HashDocAttributeSet());
DocPrintJob job = service.createPrintJob();
job.addPrintJobListener(new PrintJobAdapter() {
@Override
public void printJobCompleted(PrintJobEvent pje) {
testPrintAndExit();
}
});
job.print(doc, new HashPrintRequestAttributeSet());
}