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


Java PrintServiceLookup.lookupDefaultPrintService方法代码示例

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


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

示例1: lookupDefaultPrintService

import javax.print.PrintServiceLookup; //导入方法依赖的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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:RasterPrinterJob.java

示例2: getPrintService

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
/**
 *
 * @param printername
 * @return
 */
public static PrintService getPrintService(String printername) {
    
    // Initalize print service
    
    if (printername == null) {
        return PrintServiceLookup.lookupDefaultPrintService();       
    } else {
        
        if ("(Show dialog)".equals(printername)) {
            return null; // null means "you have to show the print dialog"
        } else if ("(Default)".equals(printername)) {
            return PrintServiceLookup.lookupDefaultPrintService(); 
        } else {
            PrintService[] pservices = 
                    PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE , null);
            for (PrintService s : pservices) {    
                if (printername.equals(s.getName())) {
                    return s;
                }
            }
            return PrintServiceLookup.lookupDefaultPrintService();       
        }                
    }                 
}
 
开发者ID:gnoopy,项目名称:wifepos,代码行数:30,代码来源:ReportUtils.java

示例3: main

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
public static void main(String[] args)  throws Exception {
    prservices = PrintServiceLookup.lookupDefaultPrintService();
    if (prservices == null) {
        System.out.println("No print service found");
        return;
    }
    System.out.println(" Print service " + prservices);
    SwingUtilities.invokeAndWait(() -> {
        doTest(TestMediaTraySelection::printTest);
    });
    mainThread = Thread.currentThread();
    try {
        Thread.sleep(90000);
    } catch (InterruptedException e) {
        if (!testPassed && testGeneratedInterrupt) {
            throw new RuntimeException("Banner page did not print");
        }
    }
    if (!testGeneratedInterrupt) {
        throw new RuntimeException("user has not executed the test");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:TestMediaTraySelection.java

示例4: getPrintService

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
public static PrintService getPrintService(String printername) {
    
    // Initalize print service
    
    if (printername == null) {
        return PrintServiceLookup.lookupDefaultPrintService();       
    } else {
        
        if ("(Show dialog)".equals(printername)) {
            return null; // null means "you have to show the print dialog"
        } else if ("(Default)".equals(printername)) {
            return PrintServiceLookup.lookupDefaultPrintService(); 
        } else {
            PrintService[] pservices = 
                    PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE , null);
            for (PrintService s : pservices) {    
                if (printername.equals(s.getName())) {
                    return s;
                }
            }
            return PrintServiceLookup.lookupDefaultPrintService();       
        }                
    }                 
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:25,代码来源:ReportUtils.java

示例5: getPrintService

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
public PrintService getPrintService() {
    if (myService == null) {
        String printerName = getNativePrintService();

        if (printerName != null) {
            myService = Win32PrintServiceLookup.getWin32PrintLUS().
                getPrintServiceByName(printerName);
            // no need to call setNativePrintService as this name is
            // currently set in native
            if (myService != null) {
                return myService;
            }
        }

        myService = PrintServiceLookup.lookupDefaultPrintService();
        if (myService != null) {
            try {
                setNativePrintService(myService.getName());
            } catch (Exception e) {
                myService = null;
            }
        }

      }
      return myService;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:27,代码来源:WPrinterJob.java

示例6: out

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
public static boolean out(BufferedImage image) {
	try {
		DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
		PrintRequestAttributeSet requestAttributeSet = new HashPrintRequestAttributeSet();
		requestAttributeSet.add(MediaSizeName.ISO_A4);
		requestAttributeSet.add(new JobName(LSystem.applicationName + LSystem.getTime(), Locale.ENGLISH));
		PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, requestAttributeSet);
		PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
		PrintService service = ServiceUI.printDialog(null, 100, 100, services, defaultService, flavor,
				requestAttributeSet);
		if (service != null) {
			DocPrintJob job = service.createPrintJob();
			SimpleDoc doc = new SimpleDoc(new BufferedImagePrintable(image), flavor, null);
			job.print(doc, requestAttributeSet);
		}
	} catch (Exception e) {
		return false;
	}
	return true;
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:21,代码来源:PrintImageOutput.java

示例7: getPrintService

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
public PrintService getPrintService() {
    if (myService == null) {
        String printerName = getNativePrintService();

        if (printerName != null) {
            myService = Win32PrintServiceLookup.getWin32PrintLUS().
                getPrintServiceByName(printerName);
            // no need to call setNativePrintService as this name is
            // currently set in native
            if (myService != null) {
                return myService;
            }
        }

        myService = PrintServiceLookup.lookupDefaultPrintService();
        if (myService != null) {
            try {
                setNativePrintServiceIfNeeded(myService.getName());
            } catch (Exception e) {
                myService = null;
            }
        }

      }
      return myService;
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:27,代码来源:WPrinterJob.java

示例8: pageSetup

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
private int pageSetup(PrintService aService, 
                      PrintRequestAttributeSet requestAttrs) 
{
    myService = (aService == null)  
            ? PrintServiceLookup.lookupDefaultPrintService() 
            : aService;
    
    if ((requestAttrs == null) || (aService == null)) {
        return SETUP_ERROR;
    }
    
    attrs = requestAttrs;
    newAttrs = new HashPrintRequestAttributeSet(attrs);
    myService = aService;
    
    prepareDialog();        // prepare dialog
    fillPageSetupFields();  // Initialize dialog fields
    firstUse = false;
    return SETUP_OK;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:ServiceUIDialog.java

示例9: initSelection

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
private void initSelection(){
	if (selPrinter == null) {
		PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
		if (defaultPrintService != null && printServices.contains(defaultPrintService)) {
			cvPrinters.setSelection(new StructuredSelection(defaultPrintService));
		}
	} else {
		for (PrintService ps : printServices) {
			if (ps.getName().equals(selPrinter)) {
				cvPrinters.setSelection(new StructuredSelection(ps));
			}
		}
	}
	
	if (!mediaTrays.isEmpty()) {
		if (selTray == null) {
			cvTrays.setSelection(new StructuredSelection(mediaTrays.get(0)));
		} else {
			for (MediaTray mt : mediaTrays) {
				if (mt.toString().equals(selTray)) {
					cvTrays.setSelection(new StructuredSelection(mt));
				}
			}
		}
	}
}
 
开发者ID:elexis,项目名称:elexis-3-core,代码行数:27,代码来源:TextTemplatePrintSettingsDialog.java

示例10: getWin32PrintLUS

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
public static Win32PrintServiceLookup getWin32PrintLUS() {
    if (win32PrintLUS == null) {
        /* This call is internally synchronized.
         * When it returns an instance of this class will have
         * been instantiated - else there's a JDK internal error.
         */
        PrintServiceLookup.lookupDefaultPrintService();
    }
    return win32PrintLUS;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:Win32PrintServiceLookup.java

示例11: getPrintService

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
@Override
public PrintService getPrintService() {
    if (myService == null) {
        String printerName = getNativePrintService();

        if (printerName != null) {
            myService = Win32PrintServiceLookup.getWin32PrintLUS().
                getPrintServiceByName(printerName);
            // no need to call setNativePrintService as this name is
            // currently set in native
            if (myService != null) {
                return myService;
            }
        }

        myService = PrintServiceLookup.lookupDefaultPrintService();
        if (myService instanceof Win32PrintService) {
            try {
                setNativePrintServiceIfNeeded(myService.getName());
            } catch (Exception e) {
                myService = null;
            }
        }

      }
      return myService;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:WPrinterJob.java

示例12: trial

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
static void trial() {
    PrintService pserv1 = PrintServiceLookup.lookupDefaultPrintService();
    PrintService[] pservs = PrintServiceLookup.lookupPrintServices(null, null);
    PrintService pserv2 = PrintServiceLookup.lookupDefaultPrintService();

    if ((pserv1 == null) || (pserv2==null)) {
        return;
    }

    if (pserv1.hashCode() != pserv2.hashCode()) {
        throw new RuntimeException("Different hashCodes for equal print "
                        + "services: " + pserv1.hashCode() + " "
                        + pserv2.hashCode());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:TestRaceCond.java

示例13: getWin32PrintLUS

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
public static PrintServiceLookupProvider getWin32PrintLUS() {
    if (win32PrintLUS == null) {
        /* This call is internally synchronized.
         * When it returns an instance of this class will have
         * been instantiated - else there's a JDK internal error.
         */
        PrintServiceLookup.lookupDefaultPrintService();
    }
    return win32PrintLUS;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:PrintServiceLookupProvider.java

示例14: getPrintService

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
@Override
public PrintService getPrintService() {
    if (myService == null) {
        String printerName = getNativePrintService();

        if (printerName != null) {
            myService = PrintServiceLookupProvider.getWin32PrintLUS().
                getPrintServiceByName(printerName);
            // no need to call setNativePrintService as this name is
            // currently set in native
            if (myService != null) {
                return myService;
            }
        }

        myService = PrintServiceLookup.lookupDefaultPrintService();
        if (myService instanceof Win32PrintService) {
            try {
                setNativePrintServiceIfNeeded(myService.getName());
            } catch (Exception e) {
                myService = null;
            }
        }

      }
      return myService;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:WPrinterJob.java

示例15: printTest

import javax.print.PrintServiceLookup; //导入方法依赖的package包/类
private static void printTest() {
    ServiceDlgSheetCollateTest pd = new ServiceDlgSheetCollateTest();
    DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
    //DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
    PrintService defService = null, service[] = null;
    defService = PrintServiceLookup.lookupDefaultPrintService();
    service = PrintServiceLookup.lookupPrintServices(flavor, null);

    if ((service == null) || (service.length == 0)) {
        throw new RuntimeException("No Printer services found");
    }
    if (defService != null) {
        System.out.println("\nDefault print service: " + service );
        System.out.println("is flavor: "+flavor+" supported? "+
                        defService.isDocFlavorSupported(flavor));
        System.out.println("is SheetCollate category supported? "+
              defService.isAttributeCategorySupported(SheetCollate.class));
        System.out.println("is SheetCollate.COLLATED value supported ? "+
              defService.isAttributeValueSupported(SheetCollate.COLLATED,
                                                        flavor, null));
    }
    HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
    try {
        PrintService selService = ServiceUI.printDialog(null, 200, 200, service, defService, flavor, prSet);
    } catch (IllegalArgumentException ia) {
        System.out.println("Exception thrown : " + ia);
    }

    System.out.println("\nSelected Values\n");
    Attribute attr[] = prSet.toArray();
    for (int x = 0; x < attr.length; x ++) {
        System.out.println("Attribute: " + attr[x].getName() + " Value: " + attr[x]);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:ServiceDlgSheetCollateTest.java


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