📄 e713. listening for print service status changes.txt
字号:
Examples of print service status include PrinterIsAcceptingJobs (indicates if a print service will accept new print jobs) and QueuedJobCount (the number of print jobs to be processed by the print service). Use a PrintServiceAttributeListener to get status changes on a print server. This example adds a listener to all print services. To obtain detailed status changes for a print job, see e714 Listening for Print Job Status Changes.
// Add a listener to all print services
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
for (int i=0; i<services.length; i++) {
services[i].addPrintServiceAttributeListener(new MyPrintServiceAttributeListener());
}
class MyPrintServiceAttributeListener implements PrintServiceAttributeListener {
public void attributeUpdate(PrintServiceAttributeEvent psae) {
// Some event occurred with a print service
PrintService service = psae.getPrintService();
Attribute[] attrs = psae.getAttributes().toArray();
for (int i=0; i<attrs.length; i++) {
String attrName = attrs[i].getName();
// New value
String attrValue = attrs[i].toString();
process(service, attrName, attrValue);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -