use of javax.print.event.PrintJobEvent in project jdk8u_jdk by JetBrains.
the class PrintSEUmlauts method main.
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());
}
use of javax.print.event.PrintJobEvent in project jdk8u_jdk by JetBrains.
the class UnixPrintJob method notifyEvent.
private void notifyEvent(int reason) {
/* since this method should always get called, here's where
* we will perform the clean up of any data stream supplied.
*/
switch(reason) {
case PrintJobEvent.DATA_TRANSFER_COMPLETE:
case PrintJobEvent.JOB_CANCELED:
case PrintJobEvent.JOB_FAILED:
case PrintJobEvent.NO_MORE_EVENTS:
case PrintJobEvent.JOB_COMPLETE:
closeDataStreams();
}
synchronized (this) {
if (jobListeners != null) {
PrintJobListener listener;
PrintJobEvent event = new PrintJobEvent(this, reason);
for (int i = 0; i < jobListeners.size(); i++) {
listener = (PrintJobListener) (jobListeners.elementAt(i));
switch(reason) {
case PrintJobEvent.JOB_CANCELED:
listener.printJobCanceled(event);
break;
case PrintJobEvent.JOB_FAILED:
listener.printJobFailed(event);
break;
case PrintJobEvent.DATA_TRANSFER_COMPLETE:
listener.printDataTransferCompleted(event);
break;
case PrintJobEvent.NO_MORE_EVENTS:
listener.printJobNoMoreEvents(event);
break;
default:
break;
}
}
}
}
}
use of javax.print.event.PrintJobEvent in project jdk8u_jdk by JetBrains.
the class PSStreamPrintJob method notifyEvent.
private void notifyEvent(int reason) {
synchronized (this) {
if (jobListeners != null) {
PrintJobListener listener;
PrintJobEvent event = new PrintJobEvent(this, reason);
for (int i = 0; i < jobListeners.size(); i++) {
listener = (PrintJobListener) (jobListeners.elementAt(i));
switch(reason) {
case PrintJobEvent.JOB_CANCELED:
listener.printJobCanceled(event);
break;
case PrintJobEvent.JOB_FAILED:
listener.printJobFailed(event);
break;
case PrintJobEvent.DATA_TRANSFER_COMPLETE:
listener.printDataTransferCompleted(event);
break;
case PrintJobEvent.NO_MORE_EVENTS:
listener.printJobNoMoreEvents(event);
break;
case PrintJobEvent.JOB_COMPLETE:
listener.printJobCompleted(event);
break;
default:
break;
}
}
}
}
}
use of javax.print.event.PrintJobEvent in project jdk8u_jdk by JetBrains.
the class Win32PrintJob method notifyEvent.
private void notifyEvent(int reason) {
/* since this method should always get called, here's where
* we will perform the clean up of any data stream supplied.
*/
switch(reason) {
case PrintJobEvent.DATA_TRANSFER_COMPLETE:
case PrintJobEvent.JOB_CANCELED:
case PrintJobEvent.JOB_FAILED:
case PrintJobEvent.NO_MORE_EVENTS:
case PrintJobEvent.JOB_COMPLETE:
closeDataStreams();
}
synchronized (this) {
if (jobListeners != null) {
PrintJobListener listener;
PrintJobEvent event = new PrintJobEvent(this, reason);
for (int i = 0; i < jobListeners.size(); i++) {
listener = (PrintJobListener) (jobListeners.elementAt(i));
switch(reason) {
case PrintJobEvent.JOB_COMPLETE:
listener.printJobCompleted(event);
break;
case PrintJobEvent.JOB_CANCELED:
listener.printJobCanceled(event);
break;
case PrintJobEvent.JOB_FAILED:
listener.printJobFailed(event);
break;
case PrintJobEvent.DATA_TRANSFER_COMPLETE:
listener.printDataTransferCompleted(event);
break;
case PrintJobEvent.NO_MORE_EVENTS:
listener.printJobNoMoreEvents(event);
break;
default:
break;
}
}
}
}
}
Aggregations