javax.print.attribute.standard.PageRanges Java Examples

The following examples show how to use javax.print.attribute.standard.PageRanges. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WPrinterJob.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #2
Source File: WPrinterJob.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #3
Source File: CPrinterJob.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
    super.setAttributes(attributes);

    if (attributes == null) {
        return;
    }

    PageRanges pageRangesAttr =  (PageRanges)attributes.get(PageRanges.class);
    if (isSupportedValue(pageRangesAttr, attributes)) {
        SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
        // If rangeSelect is not null, we are using AWT's print dialog that has
        // All, Selection, and Range radio buttons
        if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
            int[][] range = pageRangesAttr.getMembers();
            // setPageRange will set firstPage and lastPage as called in getFirstPage
            // and getLastPage
            setPageRange(range[0][0] - 1, range[0][1] - 1);
        }
    }
}
 
Example #4
Source File: PrintAttributeUpdateTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    String[] instructions
            = {
                "Select Pages Range From instead of All in print dialog. ",
                "Then select Print"
            };
    SwingUtilities.invokeAndWait(() -> {
        JOptionPane.showMessageDialog((Component) null,
                instructions, "Instructions",
                JOptionPane.INFORMATION_MESSAGE);
    });
    HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet();
    PrinterJob j = PrinterJob.getPrinterJob();
    j.setPageable(new PrintAttributeUpdateTest());
    as.add(DialogTypeSelection.NATIVE);
    j.printDialog(as);
    if (as.containsKey(PageRanges.class) == false) {
        throw new RuntimeException("Print Dialog did not update "
                + " attribute set with page range");
    }
    Attribute attrs[] = as.toArray();
    for (int i = 0; i < attrs.length; i++) {
        System.out.println("attr " + attrs[i]);
    }
    j.print(as);
}
 
Example #5
Source File: WPrinterJob.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #6
Source File: WPrinterJob.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #7
Source File: CPrinterJob.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
    super.setAttributes(attributes);

    if (attributes == null) {
        return;
    }

    PageRanges pageRangesAttr =  (PageRanges)attributes.get(PageRanges.class);
    if (isSupportedValue(pageRangesAttr, attributes)) {
        SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
        // If rangeSelect is not null, we are using AWT's print dialog that has
        // All, Selection, and Range radio buttons
        if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
            int[][] range = pageRangesAttr.getMembers();
            // setPageRange will set firstPage and lastPage as called in getFirstPage
            // and getLastPage
            setPageRange(range[0][0] - 1, range[0][1] - 1);
        } else {
            // if rangeSelect is SunPageSelection.ALL
            // then setPageRange appropriately
            setPageRange(-1, -1);
        }
    }
}
 
Example #8
Source File: CPrinterJob.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
    super.setAttributes(attributes);

    if (attributes == null) {
        return;
    }

    PageRanges pageRangesAttr =  (PageRanges)attributes.get(PageRanges.class);
    if (isSupportedValue(pageRangesAttr, attributes)) {
        SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
        // If rangeSelect is not null, we are using AWT's print dialog that has
        // All, Selection, and Range radio buttons
        if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
            int[][] range = pageRangesAttr.getMembers();
            // setPageRange will set firstPage and lastPage as called in getFirstPage
            // and getLastPage
            setPageRange(range[0][0] - 1, range[0][1] - 1);
        }
    }
}
 
Example #9
Source File: PrintAttributeUpdateTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    String[] instructions
            = {
                "Select Pages Range From instead of All in print dialog. ",
                "Then select Print"
            };
    SwingUtilities.invokeAndWait(() -> {
        JOptionPane.showMessageDialog((Component) null,
                instructions, "Instructions",
                JOptionPane.INFORMATION_MESSAGE);
    });
    HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet();
    PrinterJob j = PrinterJob.getPrinterJob();
    j.setPageable(new PrintAttributeUpdateTest());
    as.add(DialogTypeSelection.NATIVE);
    j.printDialog(as);
    if (as.containsKey(PageRanges.class) == false) {
        throw new RuntimeException("Print Dialog did not update "
                + " attribute set with page range");
    }
    Attribute attrs[] = as.toArray();
    for (int i = 0; i < attrs.length; i++) {
        System.out.println("attr " + attrs[i]);
    }
    j.print(as);
}
 
Example #10
Source File: ServiceDlgPageRangeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Starts the application.
 */
public static void printTest() {

    System.out.println("\nDefault print service: " +
                          PrintServiceLookup.lookupDefaultPrintService());
    System.out.println("is flavor: "+flavor+" supported? "+
                                 services[0].isDocFlavorSupported(flavor));
    System.out.println("is Page Ranges category supported? "+
               services[0].isAttributeCategorySupported(PageRanges.class));
    System.out.println("is PageRanges[2] value supported ? "+
               services[0].isAttributeValueSupported(
                                         new PageRanges(2), flavor, null));

    HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
    //prSet.add(new PageRanges(2));
    PrintService selService = ServiceUI.printDialog(null, 200, 200,
                                      services, services[0], flavor, prSet);

    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]);
    }
}
 
Example #11
Source File: PrintAttributeUpdateTest.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    String[] instructions
            = {
                "Select Pages Range From instead of All in print dialog. ",
                "Then select Print"
            };
    SwingUtilities.invokeAndWait(() -> {
        JOptionPane.showMessageDialog((Component) null,
                instructions, "Instructions",
                JOptionPane.INFORMATION_MESSAGE);
    });
    HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet();
    PrinterJob j = PrinterJob.getPrinterJob();
    j.setPageable(new PrintAttributeUpdateTest());
    as.add(DialogTypeSelection.NATIVE);
    j.printDialog(as);
    if (as.containsKey(PageRanges.class) == false) {
        throw new RuntimeException("Print Dialog did not update "
                + " attribute set with page range");
    }
    Attribute attrs[] = as.toArray();
    for (int i = 0; i < attrs.length; i++) {
        System.out.println("attr " + attrs[i]);
    }
    j.print(as);
}
 
Example #12
Source File: CPrinterJob.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
    super.setAttributes(attributes);

    if (attributes == null) {
        return;
    }

    // See if this has an NSPrintInfo in it.
    NSPrintInfo nsPrintInfo = (NSPrintInfo)attributes.get(NSPrintInfo.class);
    if (nsPrintInfo != null) {
        fNSPrintInfo = nsPrintInfo.getValue();
    }

    PageRanges pageRangesAttr =  (PageRanges)attributes.get(PageRanges.class);
    if (isSupportedValue(pageRangesAttr, attributes)) {
        SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
        // If rangeSelect is not null, we are using AWT's print dialog that has
        // All, Selection, and Range radio buttons
        if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
            int[][] range = pageRangesAttr.getMembers();
            // setPageRange will set firstPage and lastPage as called in getFirstPage
            // and getLastPage
            setPageRange(range[0][0] - 1, range[0][1] - 1);
        }
    }
}
 
Example #13
Source File: WPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #14
Source File: WPrinterJob.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #15
Source File: PrintAttributeUpdateTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    String[] instructions
            = {
                "Select Pages Range From instead of All in print dialog. ",
                "Then select Print"
            };
    SwingUtilities.invokeAndWait(() -> {
        JOptionPane.showMessageDialog((Component) null,
                instructions, "Instructions",
                JOptionPane.INFORMATION_MESSAGE);
    });
    HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet();
    PrinterJob j = PrinterJob.getPrinterJob();
    j.setPageable(new PrintAttributeUpdateTest());
    as.add(DialogTypeSelection.NATIVE);
    j.printDialog(as);
    if (as.containsKey(PageRanges.class) == false) {
        throw new RuntimeException("Print Dialog did not update "
                + " attribute set with page range");
    }
    Attribute attrs[] = as.toArray();
    for (int i = 0; i < attrs.length; i++) {
        System.out.println("attr " + attrs[i]);
    }
    j.print(as);
}
 
Example #16
Source File: WPrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #17
Source File: CPrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
    super.setAttributes(attributes);

    if (attributes == null) {
        return;
    }

    PageRanges pageRangesAttr =  (PageRanges)attributes.get(PageRanges.class);
    if (isSupportedValue(pageRangesAttr, attributes)) {
        SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
        // If rangeSelect is not null, we are using AWT's print dialog that has
        // All, Selection, and Range radio buttons
        if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
            int[][] range = pageRangesAttr.getMembers();
            // setPageRange will set firstPage and lastPage as called in getFirstPage
            // and getLastPage
            setPageRange(range[0][0] - 1, range[0][1] - 1);
        }
    }
}
 
Example #18
Source File: CPrinterJob.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
    super.setAttributes(attributes);

    if (attributes == null) {
        return;
    }

    PageRanges pageRangesAttr =  (PageRanges)attributes.get(PageRanges.class);
    if (isSupportedValue(pageRangesAttr, attributes)) {
        SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
        // If rangeSelect is not null, we are using AWT's print dialog that has
        // All, Selection, and Range radio buttons
        if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
            int[][] range = pageRangesAttr.getMembers();
            // setPageRange will set firstPage and lastPage as called in getFirstPage
            // and getLastPage
            setPageRange(range[0][0] - 1, range[0][1] - 1);
        }
    }
}
 
Example #19
Source File: WPrinterJob.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example #20
Source File: CPrinterJob.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
    super.setAttributes(attributes);

    if (attributes == null) {
        return;
    }

    PageRanges pageRangesAttr =  (PageRanges)attributes.get(PageRanges.class);
    if (isSupportedValue(pageRangesAttr, attributes)) {
        SunPageSelection rangeSelect = (SunPageSelection)attributes.get(SunPageSelection.class);
        // If rangeSelect is not null, we are using AWT's print dialog that has
        // All, Selection, and Range radio buttons
        if (rangeSelect == null || rangeSelect == SunPageSelection.RANGE) {
            int[][] range = pageRangesAttr.getMembers();
            // setPageRange will set firstPage and lastPage as called in getFirstPage
            // and getLastPage
            setPageRange(range[0][0] - 1, range[0][1] - 1);
        }
    }
}
 
Example #21
Source File: PrintAttributeUpdateTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String args[]) throws Exception {
    String[] instructions
            = {
                "Select Pages Range From instead of All in print dialog. ",
                "Then select Print"
            };
    SwingUtilities.invokeAndWait(() -> {
        JOptionPane.showMessageDialog((Component) null,
                instructions, "Instructions",
                JOptionPane.INFORMATION_MESSAGE);
    });
    HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet();
    PrinterJob j = PrinterJob.getPrinterJob();
    j.setPageable(new PrintAttributeUpdateTest());
    as.add(DialogTypeSelection.NATIVE);
    j.printDialog(as);
    if (as.containsKey(PageRanges.class) == false) {
        throw new RuntimeException("Print Dialog did not update "
                + " attribute set with page range");
    }
    Attribute attrs[] = as.toArray();
    for (int i = 0; i < attrs.length; i++) {
        System.out.println("attr " + attrs[i]);
    }
    j.print(as);
}
 
Example #22
Source File: PrintPanel.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public PrintService accept(PrintRequestAttributeSet set) {
    PrintService service = super.accept(set);
    if (mCopies != null) {
        PrintUtilities.setCopies(set, ((Integer) mCopies.getValue()).intValue());
    }
    if (mPageRangeAll != null) {
        if (mPageRangeAll.isSelected()) {
            PrintUtilities.setPageRanges(set, null);
        } else {
            int start = ((Integer) mPageRangeStart.getValue()).intValue();
            int end   = ((Integer) mPageRangeEnd.getValue()).intValue();
            if (start > end) {
                int tmp = start;
                start = end;
                end = tmp;
            }
            PrintUtilities.setPageRanges(set, new PageRanges(start, end));
        }
    }
    return service;
}
 
Example #23
Source File: PrintJob2D.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void run() {

        try {
            attributes.remove(PageRanges.class);
            printerJob.print(attributes);
        } catch (PrinterException e) {
            //REMIND: need to store this away and not rethrow it.
        }

        /* Close the message queues so that nobody is stuck
         * waiting for one.
         */
        graphicsToBeDrawn.closeWhenEmpty();
        graphicsDrawn.close();
    }
 
Example #24
Source File: RasterPrinterJob.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected final int getFromPageAttrib() {
    if (attributes != null) {
        PageRanges pageRangesAttr =
            (PageRanges)attributes.get(PageRanges.class);
        if (pageRangesAttr != null) {
            int[][] range = pageRangesAttr.getMembers();
            return range[0][0];
        }
    }
    return getMinPageAttrib();
}
 
Example #25
Source File: RasterPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected final int getToPageAttrib() {
    if (attributes != null) {
        PageRanges pageRangesAttr =
            (PageRanges)attributes.get(PageRanges.class);
        if (pageRangesAttr != null) {
            int[][] range = pageRangesAttr.getMembers();
            return range[range.length-1][1];
        }
    }
    return getMaxPageAttrib();
}
 
Example #26
Source File: PrintJob2D.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void run() {

        try {
            attributes.remove(PageRanges.class);
            printerJob.print(attributes);
        } catch (PrinterException e) {
            //REMIND: need to store this away and not rethrow it.
        }

        /* Close the message queues so that nobody is stuck
         * waiting for one.
         */
        graphicsToBeDrawn.closeWhenEmpty();
        graphicsDrawn.close();
    }
 
Example #27
Source File: DlgAttrsBug.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void printTest() {
    PrinterJob job = PrinterJob.getPrinterJob();
    if (job.getPrintService() == null) {
        System.out.println("No printers. Test cannot continue");
        return;
    }
    job.setPrintable(new DlgAttrsBug());
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(new Copies(5));
    aset.add(new PageRanges(3,4));
    aset.add(DialogTypeSelection.NATIVE);
    job.printDialog(aset);
}
 
Example #28
Source File: PrintPanel.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
private void createPageRangeFields(PrintRequestAttributeSet set) {
    PrintService service = getService();
    if (service.isAttributeCategorySupported(PageRanges.class)) {
        ButtonGroup group      = new ButtonGroup();
        int         start      = 1;
        int         end        = 9999;
        PageRanges  pageRanges = (PageRanges) set.get(PageRanges.class);
        if (pageRanges != null) {
            int[][] ranges = pageRanges.getMembers();
            if (ranges.length > 0 && ranges[0].length > 1) {
                start = ranges[0][0];
                end = ranges[0][1];
            } else {
                pageRanges = null;
            }
        }
        JLabel label = new JLabel(I18n.Text("Print Range"), SwingConstants.CENTER);
        add(label, new PrecisionLayoutData().setEndHorizontalAlignment());
        JPanel wrapper = new JPanel(new PrecisionLayout().setMargins(0).setColumns(5));
        mPageRangeAll = new JRadioButton(I18n.Text("All"), pageRanges == null);
        wrapper.add(mPageRangeAll);
        mPageRangeSome = new JRadioButton(I18n.Text("Pages"), pageRanges != null);
        wrapper.add(mPageRangeSome);
        mPageRangeStart = createPageRangeField(start, wrapper);
        wrapper.add(new JLabel(I18n.Text("to"), SwingConstants.CENTER));
        mPageRangeEnd = createPageRangeField(end, wrapper);
        add(wrapper);
        group.add(mPageRangeAll);
        group.add(mPageRangeSome);
        adjustPageRanges();
        mPageRangeAll.addActionListener(this);
        mPageRangeSome.addActionListener(this);
    } else {
        mPageRangeAll = null;
        mPageRangeSome = null;
        mPageRangeStart = null;
        mPageRangeEnd = null;
    }
}
 
Example #29
Source File: RasterPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected final int getFromPageAttrib() {
    if (attributes != null) {
        PageRanges pageRangesAttr =
            (PageRanges)attributes.get(PageRanges.class);
        if (pageRangesAttr != null) {
            int[][] range = pageRangesAttr.getMembers();
            return range[0][0];
        }
    }
    return getMinPageAttrib();
}
 
Example #30
Source File: DlgAttrsBug.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static void printTest() {
    PrinterJob job = PrinterJob.getPrinterJob();
    if (job.getPrintService() == null) {
        System.out.println("No printers. Test cannot continue");
        return;
    }
    job.setPrintable(new DlgAttrsBug());
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(new Copies(5));
    aset.add(new PageRanges(3,4));
    aset.add(DialogTypeSelection.NATIVE);
    job.printDialog(aset);
}