Java 类javax.print.attribute.standard.Copies 实例源码

项目:OpenJSharp    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        defaultCopies = false;
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:jdk8u-jdk    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        defaultCopies = false;
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:jdk8u-jdk    文件:ImageableAreaTest.java   
private static void printWithoutPrintDialog() {

        final JTable table = createAuthorTable(42);
        PrintRequestAttributeSet pras
                = new HashPrintRequestAttributeSet();
        pras.add(new Copies(1));

        try {

            boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH,
                    new MessageFormat("Author Table"),
                    new MessageFormat("Page - {0}"),
                    false, pras, false);

            closeFrame();
            if (!printAccepted) {
                throw new RuntimeException("User cancels the printer job!");
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
项目:openjdk-jdk10    文件:WPrinterJob.java   
private void setRangeCopiesAttribute(int from, int to, boolean isRangeSet,
                                     int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        defaultCopies = false;
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:openjdk-jdk10    文件:ImageableAreaTest.java   
private static void printWithoutPrintDialog() {

        final JTable table = createAuthorTable(50);
        PrintRequestAttributeSet pras
                = new HashPrintRequestAttributeSet();
        pras.add(new Copies(1));

        try {

            boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH,
                    new MessageFormat("Author Table"),
                    new MessageFormat("Page - {0}"),
                    false, pras, false);

            closeFrame();
            if (!printAccepted) {
                throw new RuntimeException("User cancels the printer job!");
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
项目:scorekeeperfrontend    文件:EntryPanel.java   
@Override
public void actionPerformed(ActionEvent e)
{
    try {
        if (selectedDriver == null)
            return;

        PrintService ps = (PrintService)printers.getSelectedItem();
        PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();

        attr.add(new Copies(1));
        attr.add((Media)ps.getDefaultAttributeValue(Media.class)); // set to default paper from printer
        attr.add(OrientationRequested.LANDSCAPE);

        SimpleDoc doc = new SimpleDoc(activeLabel, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
        ps.createPrintJob().print(doc, attr);
    }  catch (PrintException ex) {
        log.log(Level.SEVERE, "\bBarcode print failed: " + ex.getMessage(), ex);
    }
}
项目:openjdk9    文件:WPrinterJob.java   
private void setRangeCopiesAttribute(int from, int to, boolean isRangeSet,
                                     int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        defaultCopies = false;
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:openjdk9    文件:ImageableAreaTest.java   
private static void printWithoutPrintDialog() {

        final JTable table = createAuthorTable(50);
        PrintRequestAttributeSet pras
                = new HashPrintRequestAttributeSet();
        pras.add(new Copies(1));

        try {

            boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH,
                    new MessageFormat("Author Table"),
                    new MessageFormat("Page - {0}"),
                    false, pras, false);

            closeFrame();
            if (!printAccepted) {
                throw new RuntimeException("User cancels the printer job!");
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
项目:erp    文件:ImprimeLayout.java   
public boolean imprimir(boolean bMonta) {
    if (bMonta)
        montaG();

    boolean bRet = false;
    PrinterJob printJob = PrinterJob.getPrinterJob();
    PrintRequestAttributeSet aset = Funcoes.getImpAtrib();
    if (printJob.printDialog(aset)) {
        try {
            printJob.setPrintable(this, new PaginaPad(printJob.defaultPage().getPaper()));
            printJob.print(aset);
            aset.remove(Copies.class);

            Funcoes.setImpAtrib(aset);
            bRet = true;
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    return bRet;
}
项目:jdk8u_jdk    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        defaultCopies = false;
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:jdk8u_jdk    文件:ImageableAreaTest.java   
private static void printWithoutPrintDialog() {

        final JTable table = createAuthorTable(42);
        PrintRequestAttributeSet pras
                = new HashPrintRequestAttributeSet();
        pras.add(new Copies(1));

        try {

            boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH,
                    new MessageFormat("Author Table"),
                    new MessageFormat("Page - {0}"),
                    false, pras, false);

            closeFrame();
            if (!printAccepted) {
                throw new RuntimeException("User cancels the printer job!");
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
项目:lookaside_java-1.8.0-openjdk    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        defaultCopies = false;
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ImageableAreaTest.java   
private static void printWithoutPrintDialog() {

        final JTable table = createAuthorTable(42);
        PrintRequestAttributeSet pras
                = new HashPrintRequestAttributeSet();
        pras.add(new Copies(1));

        try {

            boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH,
                    new MessageFormat("Author Table"),
                    new MessageFormat("Page - {0}"),
                    false, pras, false);

            closeFrame();
            if (!printAccepted) {
                throw new RuntimeException("User cancels the printer job!");
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
项目:Camel    文件:PrinterProducer.java   
private PrintRequestAttributeSet assignPrintAttributes() throws PrintException {
    PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
    if (config.getCopies() >= 1) {
        printRequestAttributeSet.add(new Copies(config.getCopies()));
    } else {
        throw new PrintException("Number of print copies should be greater than zero");
    }
    printRequestAttributeSet.add(config.getMediaSizeName());
    printRequestAttributeSet.add(config.getInternalSides());
    printRequestAttributeSet.add(config.getInternalOrientation());

    if (config.getMediaTray() != null) {
        MediaTray mediaTray = resolveMediaTray(config.getMediaTray());

        if (mediaTray == null) {
            throw new PrintException("mediatray not found " + config.getMediaTray());
        }

        printRequestAttributeSet.add(mediaTray);
    }

    return printRequestAttributeSet;
}
项目:metasfresh    文件:PrintUtil.java   
/**
 *  Print (async)
 *  @param printerName optional printer name
 *  @param jobName optional printer job name
 *  @param pageable pageable
 *  @param copies number of copies
 *  @param withDialog if true, shows printer dialog
 */
static public void print (Pageable pageable, String printerName, String jobName,
    int copies, boolean withDialog)
{
    if (pageable == null)
        return;
    String name = "Adempiere_";
    if (jobName != null)
        name += jobName;
    //
    PrinterJob job = CPrinter.getPrinterJob(printerName);
    job.setJobName (name);
    job.setPageable (pageable);
    //  Attributes
    HashPrintRequestAttributeSet prats = new HashPrintRequestAttributeSet();
    prats.add(new Copies(copies));
    //  Set Orientation
    if (pageable.getPageFormat(0).getOrientation() == PageFormat.PORTRAIT)
        prats.add(OrientationRequested.PORTRAIT);
    else
        prats.add(OrientationRequested.LANDSCAPE);
    prats.add(new JobName(name, Language.getLoginLanguage().getLocale()));
    prats.add(getJobPriority(pageable.getNumberOfPages(), copies, withDialog));
    //
    print (job, prats, withDialog, false);
}
项目:infobip-open-jdk-8    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        defaultCopies = false;
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:jdk8u-dev-jdk    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        defaultCopies = false;
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:jdk7-jdk    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:openjdk-source-code-learn    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:OLD-OpenJDK8    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        defaultCopies = false;
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:cn1    文件:DevmodeStructWrapper.java   
public void setAttribute(final Attribute attr) {
    final Class<? extends Attribute> category = attr.getCategory();

    if (OrientationRequested.class.equals(category)) {
        setOrientation((OrientationRequested) attr);
    } else if (MediaSize.class.equals(category)) {
        setPaper((MediaSize) attr);
    } else if (Media.class.equals(category)) {
        setPaper((MediaSizeName) attr);
    } else if (Paper.class.equals(category)) {
        setPaper((Paper) attr);
    } else if (Copies.class.equals(category)) {
        setCopies((Copies) attr);
    } else if (PrintQuality.class.equals(category)) {
        setPrintQuality((PrintQuality) attr);
    } else if (Sides.class.equals(category)) {
        setSides((Sides) attr);
    } else if (SheetCollate.class.equals(category)) {
        setCollate((SheetCollate) attr);
    } else if (PrinterResolution.class.equals(category)) {
        setPrinterResolution((PrinterResolution) attr);
    } else if (Chromaticity.class.equals(category)) {
        setChromaticity((Chromaticity) attr);
    }
}
项目:cn1    文件:GDIClient.java   
public Object getDefaultAttributeValue(Class category) {
    if (category.equals(JobName.class)) {
        return new JobName("Java GDI client print job", Locale.US);
    } else if (category.equals(RequestingUserName.class)) {
        return new RequestingUserName(System.getProperty("user.name"),
                Locale.US);
    } else if (category.equals(Destination.class)) {
        File file = new File(System.getProperty("user.dir") +
                File.separator + "output.prn");
        return new Destination(file.toURI());
    } else if (category.equals(SheetCollate.class)) {
        return SheetCollate.COLLATED;
    } else if (category.equals(Copies.class)) {
        return new Copies(1);
    }
    return null;
}
项目:openjdk-jdk7u-jdk    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:freeVM    文件:GDIClient.java   
public Object getDefaultAttributeValue(Class category) {
    if (category.equals(JobName.class)) {
        return new JobName("Java GDI client print job", Locale.US);
    } else if (category.equals(RequestingUserName.class)) {
        return new RequestingUserName(System.getProperty("user.name"),
                Locale.US);
    } else if (category.equals(Destination.class)) {
        File file = new File(System.getProperty("user.dir") +
                File.separator + "output.prn");
        return new Destination(file.toURI());
    } else if (category.equals(SheetCollate.class)) {
        return SheetCollate.COLLATED;
    } else if (category.equals(Copies.class)) {
        return new Copies(1);
    }
    return null;
}
项目:freeVM    文件:DevmodeStructWrapper.java   
public void setAttribute(final Attribute attr) {
    final Class<? extends Attribute> category = attr.getCategory();

    if (OrientationRequested.class.equals(category)) {
        setOrientation((OrientationRequested) attr);
    } else if (MediaSize.class.equals(category)) {
        setPaper((MediaSize) attr);
    } else if (Media.class.equals(category)) {
        setPaper((MediaSizeName) attr);
    } else if (Paper.class.equals(category)) {
        setPaper((Paper) attr);
    } else if (Copies.class.equals(category)) {
        setCopies((Copies) attr);
    } else if (PrintQuality.class.equals(category)) {
        setPrintQuality((PrintQuality) attr);
    } else if (Sides.class.equals(category)) {
        setSides((Sides) attr);
    } else if (SheetCollate.class.equals(category)) {
        setCollate((SheetCollate) attr);
    } else if (PrinterResolution.class.equals(category)) {
        setPrinterResolution((PrinterResolution) attr);
    } else if (Chromaticity.class.equals(category)) {
        setChromaticity((Chromaticity) attr);
    }
}
项目:freeVM    文件:GDIClient.java   
public Object getDefaultAttributeValue(Class category) {
    if (category.equals(JobName.class)) {
        return new JobName("Java GDI client print job", Locale.US);
    } else if (category.equals(RequestingUserName.class)) {
        return new RequestingUserName(System.getProperty("user.name"),
                Locale.US);
    } else if (category.equals(Destination.class)) {
        File file = new File(System.getProperty("user.dir") +
                File.separator + "output.prn");
        return new Destination(file.toURI());
    } else if (category.equals(SheetCollate.class)) {
        return SheetCollate.COLLATED;
    } else if (category.equals(Copies.class)) {
        return new Copies(1);
    }
    return null;
}
项目:openjdk-icedtea7    文件:WPrinterJob.java   
private final void setRangeCopiesAttribute(int from, int to,
                                           boolean isRangeSet,
                                           int copies) {
    if (attributes != null) {
        if (isRangeSet) {
            attributes.add(new PageRanges(from, to));
            setPageRange(from, to);
        }
        attributes.add(new Copies(copies));
        /* Since this is called from native to tell Java to sync
         * up with native, we don't call this class's own setCopies()
         * method which is mainly to send the value down to native
         */
        super.setCopies(copies);
        mAttCopies = copies;
    }
}
项目:monsiaj    文件:PDFPrint.java   
public static void print(File file, int copies, PrintService ps) {
    logger.debug("print start - " + file);
    try {
        try (PDDocument document = PDDocument.load(file)) {
            MediaSizeName size = getMediaSizeName(document);

            PrinterJob job = PrinterJob.getPrinterJob();
            job.setPrintService(ps);
            job.setPageable(new PDFPageable(document));
            PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
            attr.add(size);
            attr.add(new Copies(copies));
            attr.add(new JobName(file.getName(), null));

            PageFormat pf = job.getPageFormat(attr);
            Paper paper = pf.getPaper();
            paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
            pf.setPaper(paper);

            job.print(attr);
        }
    } catch (IOException | PrinterException ex) {
        logger.warn(ex, ex);
    }
    logger.debug("print end - " + file);
}
项目:OpenJSharp    文件:Win32PrintService.java   
private boolean isSupportedCopies(Copies copies) {
    synchronized (this) {
        if (gotCopies == false) {
            nCopies = getCopiesSupported(printer, getPort());
            gotCopies = true;
        }
    }
    int numCopies = copies.getValue();
    return (numCopies > 0 && numCopies <= nCopies);
}
项目:OpenJSharp    文件:Win32PrintService.java   
private boolean isPSDocAttr(Class category) {
    if (category == OrientationRequested.class || category == Copies.class) {
            return true;
    }
    else {
        return false;
    }
}
项目:OpenJSharp    文件:Win32PrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new sun.awt.windows.WPrinterJob();
            }
        }
        PrintService svc = getPrintService();
        job.setPrintService(svc);
        if (copies == 0) {
            Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class);
            copies = c.getValue();
        }
        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);
    }
}
项目:OpenJSharp    文件:Win32PrintService.java   
private boolean isPSDocAttr(Class category) {
    if (category == OrientationRequested.class || category == Copies.class) {
            return true;
    }
    else {
        return false;
    }
}
项目:jdk8u-jdk    文件:Win32PrintService.java   
private boolean isSupportedCopies(Copies copies) {
    synchronized (this) {
        if (gotCopies == false) {
            nCopies = getCopiesSupported(printer, getPort());
            gotCopies = true;
        }
    }
    int numCopies = copies.getValue();
    return (numCopies > 0 && numCopies <= nCopies);
}
项目:jdk8u-jdk    文件:Win32PrintService.java   
private boolean isPSDocAttr(Class category) {
    if (category == OrientationRequested.class || category == Copies.class) {
            return true;
    }
    else {
        return false;
    }
}
项目:jdk8u-jdk    文件:Win32PrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new sun.awt.windows.WPrinterJob();
            }
        }
        PrintService svc = getPrintService();
        job.setPrintService(svc);
        if (copies == 0) {
            Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class);
            copies = c.getValue();
        }
        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);
    }
}
项目:jdk8u-jdk    文件:ImageableAreaTest.java   
private static void printWithCustomImageareaSize() {
    final JTable table = createAuthorTable(18);
    PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
    printAttributes.add(DialogTypeSelection.NATIVE);
    printAttributes.add(new Copies(1));
    printAttributes.add(new MediaPrintableArea(
            0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH));
    Printable printable = table.getPrintable(
            JTable.PrintMode.NORMAL,
            new MessageFormat("Author Table"),
            new MessageFormat("Page - {0}")
    );

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(printable);

    boolean printAccepted = job.printDialog(printAttributes);
    if (printAccepted) {
        try {
            job.print(printAttributes);
            closeFrame();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else {
        throw new RuntimeException("User cancels the printer job!");
    }
}
项目:openjdk-jdk10    文件:Win32PrintService.java   
private boolean isSupportedCopies(Copies copies) {
    synchronized (this) {
        if (gotCopies == false) {
            nCopies = getCopiesSupported(printer, getPort());
            gotCopies = true;
        }
    }
    int numCopies = copies.getValue();
    return (numCopies > 0 && numCopies <= nCopies);
}
项目:openjdk-jdk10    文件:Win32PrintService.java   
private boolean isPSDocAttr(Class<?> category) {
    if (category == OrientationRequested.class || category == Copies.class) {
            return true;
    }
    else {
        return false;
    }
}
项目:openjdk-jdk10    文件:Win32PrintJob.java   
public void pageableJob(Pageable pageable) throws PrintException {
    try {
        synchronized(this) {
            if (job != null) { // shouldn't happen
                throw new PrintException("already printing");
            } else {
                job = new sun.awt.windows.WPrinterJob();
            }
        }
        PrintService svc = getPrintService();
        job.setPrintService(svc);
        if (copies == 0) {
            Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class);
            copies = c.getValue();
        }
        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);
    }
}
项目:openjdk-jdk10    文件:ImageableAreaTest.java   
private static void printWithCustomImageareaSize() {
    final JTable table = createAuthorTable(18);
    PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
    printAttributes.add(DialogTypeSelection.NATIVE);
    printAttributes.add(new Copies(1));
    printAttributes.add(new MediaPrintableArea(
            0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH));
    Printable printable = table.getPrintable(
            JTable.PrintMode.NORMAL,
            new MessageFormat("Author Table"),
            new MessageFormat("Page - {0}")
    );

    PrinterJob job = PrinterJob.getPrinterJob();
    job.setPrintable(printable);

    boolean printAccepted = job.printDialog(printAttributes);
    if (printAccepted) {
        try {
            job.print(printAttributes);
            closeFrame();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else {
        throw new RuntimeException("User cancels the printer job!");
    }
}