当前位置: 首页>>代码示例>>Java>>正文


Java PrintJobEvent类代码示例

本文整理汇总了Java中javax.print.event.PrintJobEvent的典型用法代码示例。如果您正苦于以下问题:Java PrintJobEvent类的具体用法?Java PrintJobEvent怎么用?Java PrintJobEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrintJobEvent类属于javax.print.event包,在下文中一共展示了PrintJobEvent类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: notifyPrintJobListeners

import javax.print.event.PrintJobEvent; //导入依赖的package包/类
private void notifyPrintJobListeners(PrintJobEvent e)
{
  Iterator it = printJobListener.iterator();
  while (it.hasNext())
    {
      PrintJobListener l = (PrintJobListener) it.next();
      if (e.getPrintEventType() == PrintJobEvent.DATA_TRANSFER_COMPLETE)
        l.printDataTransferCompleted(e);
      else if (e.getPrintEventType() == PrintJobEvent.JOB_CANCELED)
        l.printJobCanceled(e);
      else if (e.getPrintEventType() == PrintJobEvent.JOB_COMPLETE)
        l.printJobCompleted(e);
      else if (e.getPrintEventType() == PrintJobEvent.JOB_FAILED)
        l.printJobFailed(e);
      else if (e.getPrintEventType() == PrintJobEvent.NO_MORE_EVENTS)
        l.printJobNoMoreEvents(e);
      else
        l.printJobRequiresAttention(e);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:21,代码来源:DocPrintJobImpl.java

示例2: pageableJob

import javax.print.event.PrintJobEvent; //导入依赖的package包/类
public void pageableJob(Pageable pageable,
                        PrintRequestAttributeSet attributes)
    throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setPageable(pageable);
        job.print(attributes);
        notifyEvent(PrintJobEvent.JOB_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:PSStreamPrintJob.java

示例3: pageableJob

import javax.print.event.PrintJobEvent; //导入依赖的package包/类
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new PSPrinterJob();
            }
        }
        job.setPrintService(getPrintService());
        job.setCopies(copies);
        job.setJobName(jobName);
        job.setPageable(pageable);
        job.print(reqAttrSet);
        notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
        return;
    } catch (PrinterException pe) {
        notifyEvent(PrintJobEvent.JOB_FAILED);
        throw new PrintException(pe);
    } finally {
        printReturned = true;
        notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:UnixPrintJob.java

示例4: run

import javax.print.event.PrintJobEvent; //导入依赖的package包/类
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:UnixPrintJob.java

示例5: main

import javax.print.event.PrintJobEvent; //导入依赖的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());
    }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:PrintSEUmlauts.java

示例6: run

import javax.print.event.PrintJobEvent; //导入依赖的package包/类
public OutputStream run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = Files.createTempFile("javaprint", "").toFile();
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:UnixPrintJob.java

示例7: notifyPrintJobListeners

import javax.print.event.PrintJobEvent; //导入依赖的package包/类
private void notifyPrintJobListeners(PrintJobEvent e)
{
  Iterator it = printJobListener.iterator();
  while (it.hasNext())
    {
      PrintJobListener l = (PrintJobListener) it.next();
      if (e.getPrintEventType() == PrintJobEvent.DATA_TRANSFER_COMPLETE)
        l.printDataTransferCompleted(e);
      else if (e.getPrintEventType() == PrintJobEvent.JOB_CANCELED)
        l.printJobCanceled(e);
      else if (e.getPrintEventType() == PrintJobEvent.JOB_COMPLETE)
        l.printJobCompleted(e);
      else if (e.getPrintEventType() == PrintJobEvent.JOB_FAILED)
        l.printJobFailed(e);
      else if (e.getPrintEventType() == PrintJobEvent.NO_MORE_EVENTS)
        l.printJobNoMoreEvents(e);
      else 
        l.printJobRequiresAttention(e);
    }    
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:21,代码来源:DocPrintJobImpl.java

示例8: run

import javax.print.event.PrintJobEvent; //导入依赖的package包/类
public Object run() {
    try {
        if (mDestType == UnixPrintJob.DESTFILE) {
            spoolFile = new File(mDestination);
        } else {
            /* Write to a temporary file which will be spooled to
             * the printer then deleted. In the case that the file
             * is not removed for some reason, request that it is
             * removed when the VM exits.
             */
            spoolFile = File.createTempFile("javaprint", ".ps", null);
            spoolFile.deleteOnExit();
        }
        result = new FileOutputStream(spoolFile);
        return result;
    } catch (IOException ex) {
        // If there is an IOError we subvert it to a PrinterException.
        notifyEvent(PrintJobEvent.JOB_FAILED);
        pex = new PrintException(ex);
    }
    return null;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:23,代码来源:UnixPrintJob.java

示例9: notifyJobListeners

import javax.print.event.PrintJobEvent; //导入依赖的package包/类
void notifyJobListeners(final int reason) {
    final PrintJobEvent event = new PrintJobEvent(this, reason);

    for (PrintJobListener listener : jobListeners.keySet()) {
        switch (reason) {
        case PrintJobEvent.DATA_TRANSFER_COMPLETE:
            listener.printDataTransferCompleted(event);
            break;
        case PrintJobEvent.JOB_CANCELED:
            listener.printJobCanceled(event);
            break;
        case PrintJobEvent.JOB_COMPLETE:
            listener.printJobCompleted(event);
            break;
        case PrintJobEvent.JOB_FAILED:
            listener.printJobFailed(event);
            break;
        case PrintJobEvent.NO_MORE_EVENTS:
            listener.printJobNoMoreEvents(event);
            break;
        case PrintJobEvent.REQUIRES_ATTENTION:
            listener.printJobRequiresAttention(event);
            break;
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:WinPrintJob.java


注:本文中的javax.print.event.PrintJobEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。