![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e715. Listening for Print Job Attribute ChangesStatus changes that are common to all print jobs are delivered through a print job listener; see e714 Listening for Print Job Status Changes. However, if a print service supports a status that is not supported by the print job listener (e.g.,JobMediaSheetsCompleted ), it
delivers status changes through a print job
attribute listener.
// Create the print job DocPrintJob job = service.createPrintJob(); PrintJobAttributeSet set = new HashPrintJobAttributeSet(job.getAttributes()); set.add(new JobMediaSheetsCompleted(0)); job.addPrintJobAttributeListener(new MyPrintJobAttributeListener(), set); class MyPrintJobAttributeListener implements PrintJobAttributeListener { public void attributeUpdate(PrintJobAttributeEvent pjae) { // Get the set of attributes that have changed Attribute[] attrs = pjae.getAttributes().toArray(); for (int i=0; i<attrs.length; i++) { String attrName = attrs[i].getName(); String attrValue = attrs[i].toString(); process(pjae, attrName, attrValue); } } }
e714. Listening for Print Job Status Changes © 2002 Addison-Wesley. |