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


Java PrintService.getName方法代码示例

本文整理汇总了Java中javax.print.PrintService.getName方法的典型用法代码示例。如果您正苦于以下问题:Java PrintService.getName方法的具体用法?Java PrintService.getName怎么用?Java PrintService.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.print.PrintService的用法示例。


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

示例1: main

import javax.print.PrintService; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
        String serviceName = service.getName();
        PrinterName name = service.getAttribute(PrinterName.class);
        String printerName = name.getValue();

        PrintService serviceByName = lookupByName(printerName);
        System.out.println("service " + service);
        System.out.println("serviceByName " + serviceByName);
        if (!service.equals(serviceByName)) {
            throw new RuntimeException("NOK " + serviceName
                               + " expected: " + service.getClass().getName()
                               + " got: " + serviceByName.getClass().getName());
        }
    }
    System.out.println("Test PASSED");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:GetPrintServices.java

示例2: setPrintService

import javax.print.PrintService; //导入方法依赖的package包/类
/**
 * Associate this PrinterJob with a new PrintService.
 *
 * Throws <code>PrinterException</code> if the specified service
 * cannot support the <code>Pageable</code> and
 * <code>Printable</code> interfaces necessary to support 2D printing.
 * @param a print service which supports 2D printing.
 *
 * @throws PrinterException if the specified service does not support
 * 2D printing or no longer available.
 */
public void setPrintService(PrintService service)
    throws PrinterException {
    if (service == null) {
        throw new PrinterException("Service cannot be null");
    } else if (!(service instanceof StreamPrintService) &&
               service.getName() == null) {
        throw new PrinterException("Null PrintService name.");
    } else {
        // Check the list of services.  This service may have been
        // deleted already
        PrinterState prnState = (PrinterState)service.getAttribute(
                                              PrinterState.class);
        if (prnState == PrinterState.STOPPED) {
            PrinterStateReasons prnStateReasons =
                (PrinterStateReasons)service.getAttribute(
                                             PrinterStateReasons.class);
            if ((prnStateReasons != null) &&
                (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN)))
            {
                throw new PrinterException("PrintService is no longer available.");
            }
        }


        if (service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PAGEABLE) &&
            service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            myService = service;
        } else {
            throw new PrinterException("Not a 2D print service: " + service);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:46,代码来源:RasterPrinterJob.java

示例3: ServiceNotifier

import javax.print.PrintService; //导入方法依赖的package包/类
ServiceNotifier(PrintService service) {
    super(service.getName() + " notifier");
    this.service = service;
    listeners = new Vector();
    try {
          setPriority(Thread.NORM_PRIORITY-1);
          setDaemon(true);
          start();
    } catch (SecurityException e) {
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:ServiceNotifier.java

示例4: endDoc

import javax.print.PrintService; //导入方法依赖的package包/类
/**
 * Invoked by the RasterPrintJob super class
 * this method is called after that last page
 * has been imaged.
 */
protected void endDoc() throws PrinterException {
    if (mPSStream != null) {
        mPSStream.println(EOF_COMMENT);
        mPSStream.flush();
        if (mDestType != RasterPrinterJob.STREAM) {
            mPSStream.close();
        }
    }
    if (mDestType == RasterPrinterJob.PRINTER) {
        PrintService pServ = getPrintService();
        if (pServ != null) {
            mDestination = pServ.getName();
           if (isMac) {
                PrintServiceAttributeSet psaSet = pServ.getAttributes();
                if (psaSet != null) {
                    mDestination = psaSet.get(PrinterName.class).toString() ;
                }
            }
        }
        PrinterSpooler spooler = new PrinterSpooler();
        java.security.AccessController.doPrivileged(spooler);
        if (spooler.pex != null) {
            throw spooler.pex;
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:PSPrinterJob.java

示例5: UnixPrintJob

import javax.print.PrintService; //导入方法依赖的package包/类
UnixPrintJob(PrintService service) {
    this.service = service;
    mDestination = service.getName();
    if (UnixPrintServiceLookup.isMac()) {
        mDestination = ((IPPPrintService)service).getDest();
    }
    mDestType = UnixPrintJob.DESTPRINTER;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:UnixPrintJob.java

示例6: main

import javax.print.PrintService; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
    String serviceName = service.getName();
    PrintService serviceByName = lookupByName(serviceName);
    if (!service.equals(serviceByName)) {
      throw new RuntimeException("NOK " + serviceName
                                 + " expected: " + service.getClass().getName()
                                 + " got: " + serviceByName.getClass().getName());
    }
  }
  System.out.println("Test PASSED");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:GetPrintServices.java

示例7: setPrintService

import javax.print.PrintService; //导入方法依赖的package包/类
/**
 * Associate this PrinterJob with a new PrintService.
 *
 * Throws {@code PrinterException} if the specified service
 * cannot support the {@code Pageable} and
 * {@code Printable} interfaces necessary to support 2D printing.
 * @param service print service which supports 2D printing.
 *
 * @throws PrinterException if the specified service does not support
 * 2D printing or no longer available.
 */
public void setPrintService(PrintService service)
    throws PrinterException {
    if (service == null) {
        throw new PrinterException("Service cannot be null");
    } else if (!(service instanceof StreamPrintService) &&
               service.getName() == null) {
        throw new PrinterException("Null PrintService name.");
    } else {
        // Check the list of services.  This service may have been
        // deleted already
        PrinterState prnState = service.getAttribute(PrinterState.class);
        if (prnState == PrinterState.STOPPED) {
            PrinterStateReasons prnStateReasons =
                service.getAttribute(PrinterStateReasons.class);
            if ((prnStateReasons != null) &&
                (prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN)))
            {
                throw new PrinterException("PrintService is no longer available.");
            }
        }


        if (service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PAGEABLE) &&
            service.isDocFlavorSupported(
                                         DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
            myService = service;
        } else {
            throw new PrinterException("Not a 2D print service: " + service);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:RasterPrinterJob.java

示例8: ServiceNotifier

import javax.print.PrintService; //导入方法依赖的package包/类
ServiceNotifier(PrintService service) {
    super(null, null, service.getName() + " notifier", 0, false);
    this.service = service;
    listeners = new Vector<>();
    try {
          setPriority(Thread.NORM_PRIORITY-1);
          setDaemon(true);
          start();
    } catch (SecurityException e) {
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ServiceNotifier.java

示例9: endDoc

import javax.print.PrintService; //导入方法依赖的package包/类
/**
 * Invoked by the RasterPrintJob super class
 * this method is called after that last page
 * has been imaged.
 */
protected void endDoc() throws PrinterException {
    if (mPSStream != null) {
        mPSStream.println(EOF_COMMENT);
        mPSStream.flush();
        if (mPSStream.checkError()) {
            abortDoc();
            throw new PrinterException("Error while writing to file");
        }
        if (mDestType != RasterPrinterJob.STREAM) {
            mPSStream.close();
        }
    }
    if (mDestType == RasterPrinterJob.PRINTER) {
        PrintService pServ = getPrintService();
        if (pServ != null) {
            mDestination = pServ.getName();
           if (isMac) {
                PrintServiceAttributeSet psaSet = pServ.getAttributes();
                if (psaSet != null) {
                    mDestination = psaSet.get(PrinterName.class).toString() ;
                }
            }
        }
        PrinterSpooler spooler = new PrinterSpooler();
        java.security.AccessController.doPrivileged(spooler);
        if (spooler.pex != null) {
            throw spooler.pex;
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:PSPrinterJob.java

示例10: UnixPrintJob

import javax.print.PrintService; //导入方法依赖的package包/类
UnixPrintJob(PrintService service) {
    this.service = service;
    mDestination = service.getName();
    if (PrintServiceLookupProvider.isMac()) {
        mDestination = ((IPPPrintService)service).getDest();
    }
    mDestType = UnixPrintJob.DESTPRINTER;
    JobSheets js = (JobSheets)(service.
                                  getDefaultAttributeValue(JobSheets.class));
    if (js != null && js.equals(JobSheets.NONE)) {
        mNoJobSheet = true;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:UnixPrintJob.java

示例11: getPrinterAttrib

import javax.print.PrintService; //导入方法依赖的package包/类
private final String getPrinterAttrib() {
    // getPrintService will get current print service or default if none
    PrintService service = this.getPrintService();
    String name = (service != null) ? service.getName() : null;
    return name;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:WPrinterJob.java

示例12: getPrinterDestName

import javax.print.PrintService; //导入方法依赖的package包/类
private String getPrinterDestName(PrintService ps) {
    if (isMac()) {
        return ((IPPPrintService)ps).getDest();
    }
    return ps.getName();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:7,代码来源:UnixPrintServiceLookup.java

示例13: getPrinterAttrib

import javax.print.PrintService; //导入方法依赖的package包/类
private String getPrinterAttrib() {
    // getPrintService will get current print service or default if none
    PrintService service = this.getPrintService();
    String name = (service != null) ? service.getName() : null;
    return name;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:WPrinterJob.java


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