本文整理汇总了Java中javax.print.event.PrintServiceAttributeEvent类的典型用法代码示例。如果您正苦于以下问题:Java PrintServiceAttributeEvent类的具体用法?Java PrintServiceAttributeEvent怎么用?Java PrintServiceAttributeEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrintServiceAttributeEvent类属于javax.print.event包,在下文中一共展示了PrintServiceAttributeEvent类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attributeUpdate
import javax.print.event.PrintServiceAttributeEvent; //导入依赖的package包/类
/**
* Print Service Attribute Listener.
*
* @param psae event
*/
@Override
public void attributeUpdate(PrintServiceAttributeEvent psae)
{
/**
* PrintEvent on Win32 Printer : \\MAIN\HP LaserJet 5L
* PrintServiceAttributeSet - length=2
* queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
* printer-is-accepting-jobs = accepting-jobs (class javax.print.attribute.standard.PrinterIsAcceptingJobs)
* PrintEvent on Win32 Printer : \\MAIN\HP LaserJet 5L
* PrintServiceAttributeSet - length=1
* queued-job-count = 1 (class javax.print.attribute.standard.QueuedJobCount)
* PrintEvent on Win32 Printer : \\MAIN\HP LaserJet 5L
* PrintServiceAttributeSet - length=1
* queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
**/
log.debug("attributeUpdate - " + psae);
// PrintUtil.dump (psae.getAttributes());
}
示例2: notifyListeners
import javax.print.event.PrintServiceAttributeEvent; //导入依赖的package包/类
private void notifyListeners(final PrintServiceAttribute... attrs) {
final PrintServiceAttributeEvent event = new PrintServiceAttributeEvent(
this, new HashPrintServiceAttributeSet(attrs));
for (PrintServiceAttributeListener listener : attrListeners.keySet()) {
listener.attributeUpdate(event);
}
}
示例3: run
import javax.print.event.PrintServiceAttributeEvent; //导入依赖的package包/类
public void run() {
try {
running = true;
while (running) {
Thread.sleep(1000);
for (int i = 0; i < services.size(); i++) {
PrintService service = (PrintService)services.get(i);
PrintServiceAttributeSet lastSet =
(PrintServiceAttributeSet)attributes.get(service);
PrintServiceAttributeSet newSet = service.getAttributes();
if (!lastSet.equals(newSet)) {
PrintServiceAttributeSet updated =
getUpdatedAttributeSet(lastSet, newSet);
if (updated.size() > 0) {
PrintServiceAttributeEvent event =
new PrintServiceAttributeEvent(service,updated);
ArrayList serviceListeners =
(ArrayList)listeners.get(service);
for (int j = 0; j < serviceListeners.size(); j++) {
PrintServiceAttributeListener listener =
(PrintServiceAttributeListener)
serviceListeners.get(j);
listener.attributeUpdate(event);
}
}
}
}
}
} catch (InterruptedException ie) {
// EventNotifier interrupted.
running = false;
}
}