Example usage for java.awt.print PrinterJob lookupPrintServices

List of usage examples for java.awt.print PrinterJob lookupPrintServices

Introduction

In this page you can find the example usage for java.awt.print PrinterJob lookupPrintServices.

Prototype

public static PrintService[] lookupPrintServices() 

Source Link

Document

A convenience method which looks up 2D print services.

Usage

From source file:com.turborep.turbotracker.banking.controller.BankingController.java

@RequestMapping(value = "/selectprinter", method = RequestMethod.POST)
public @ResponseBody String selectPrinter(
        @RequestParam(value = "bankAccounts", required = false) Integer bankAccountsID,
        @RequestParam(value = "checksDate", required = false) Date checkDate,
        @RequestParam(value = "checkType", required = false) String checkType,
        @RequestParam(value = "checkNumber", required = false) Integer checkNumber,
        HttpServletResponse theResponse) throws IOException {
    Motransaction aMotransaction = new Motransaction();

    PrintService[] printServices = PrinterJob.lookupPrintServices();
    StringBuilder sbr = new StringBuilder();
    String sep = "";
    for (PrintService printService : printServices) {
        sbr.append(sep);//from   ww w . ja  v a2s.c o  m
        sbr.append(printService.getName());
        sep = ",";
    }
    return sbr.toString();
}

From source file:org.pentaho.platform.plugin.action.builtin.PrintComponent.java

/**
 * Takes a printer name and find the associated PrintService. If no match can be made it randomly picks the first
 * printer listed from the call to lookupPrintServices.
 * //  w ww.  j av  a2 s.c  om
 * @param printerName
 * @return PrintService referenced by the printerName
 */
public PrintService getPrinterInternal(final String printerName, final String lastPrinterName) {
    // The parameter value was not provided, and we are allowed to create
    // user interface forms

    PrintService[] services = PrinterJob.lookupPrintServices();
    for (PrintService element : services) {
        if (element.getName().equals(printerName)) {
            return element;
        }
    }
    if (feedbackAllowed()) {
        // If it's not valid then lets find one and end this current run.
        ArrayList values = new ArrayList();
        for (PrintService element : services) {
            String value = element.getName();
            values.add(value);
        }
        createFeedbackParameter(StandardSettings.PRINTER_NAME,
                Messages.getInstance().getString("PrintComponent.USER_PRINTER_NAME"), "", lastPrinterName, //$NON-NLS-1$//$NON-NLS-2$
                values, null, "select"); //$NON-NLS-1$
        promptNeeded();
        return null;
    }
    return services[0];
}

From source file:org.pentaho.platform.plugin.action.builtin.PrintComponent.java

/**
 * Takes a printer name and find the associated PrintService. If no match can be made it randomly picks the first
 * printer listed from the call to lookupPrintServices.
 * //from   www.  j  a  v  a2 s.c  o  m
 * @param printerName
 * @return PrintService referenced by the printerName
 */
public static PrintService getPrinter(final String printerName) {
    // The parameter value was not provided, and we are allowed to create
    // user interface forms

    PrintService[] services = PrinterJob.lookupPrintServices();
    for (PrintService element : services) {
        if (element.getName().equals(printerName)) {
            return element;
        }
    }
    return services[0];
}

From source file:org.pentaho.platform.plugin.action.builtin.PrintComponent.java

public static PrintService getDefaultPrinter() {
    // The parameter value was not provided, and we are allowed to create
    // user interface forms

    PrintService[] services = PrinterJob.lookupPrintServices();
    if ((services == null) || (services.length == 0)) {
        return null;
    }/*from www.ja  v  a  2  s.c  o  m*/
    return services[0];
}