本文整理匯總了Java中javax.print.PrintService.isDocFlavorSupported方法的典型用法代碼示例。如果您正苦於以下問題:Java PrintService.isDocFlavorSupported方法的具體用法?Java PrintService.isDocFlavorSupported怎麽用?Java PrintService.isDocFlavorSupported使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.print.PrintService
的用法示例。
在下文中一共展示了PrintService.isDocFlavorSupported方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: lookupDefaultPrintService
import javax.print.PrintService; //導入方法依賴的package包/類
protected static PrintService lookupDefaultPrintService() {
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
/* Pageable implies Printable so checking both isn't strictly needed */
if (service != null &&
service.isDocFlavorSupported(
DocFlavor.SERVICE_FORMATTED.PAGEABLE) &&
service.isDocFlavorSupported(
DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
return service;
} else {
PrintService []services =
PrintServiceLookup.lookupPrintServices(
DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
if (services.length > 0) {
return services[0];
}
}
return null;
}
示例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);
}
}
}
示例3: 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);
}
}
}