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


Java PageRanges类代码示例

本文整理汇总了Java中javax.print.attribute.standard.PageRanges的典型用法代码示例。如果您正苦于以下问题:Java PageRanges类的具体用法?Java PageRanges怎么用?Java PageRanges使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setRangeCopiesAttribute

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
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;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:WPrinterJob.java

示例2: setAttributes

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:CPrinterJob.java

示例3: setAttributes

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:CPrinterJob.java

示例4: setRangeCopiesAttribute

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
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;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:WPrinterJob.java

示例5: main

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:PrintAttributeUpdateTest.java

示例6: printTest

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
/**
 * 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]);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:ServiceDlgPageRangeTest.java

示例7: print

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
public void print() {
    getPrintJob().setPrintable(this, getPage());

    boolean res;
    PrintRequestAttributeSet attr_set
            = new HashPrintRequestAttributeSet();
    if (page_range.x == 0) {
        res = getPrintJob().printDialog();
    } else {
        PrintRequestAttributeSet attr_set2
                = new HashPrintRequestAttributeSet();
        attr_set2.add(new PageRanges(page_range.x, page_range.y));
        res = getPrintJob().printDialog(attr_set2);
    }
    if (res) {
        try {
            getPrintJob().print(attr_set);
        } catch (PrinterException pe) {
            System.out.println("Error printing: " + pe);
        }
        //page = getPrintJob().getPageFormat(null);
    }

}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:25,代码来源:PrintControler.java

示例8: actionPerformed

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
public void actionPerformed(ActionEvent e)
{
  // if ALL is selected we must use a full-range object
  if (e.getActionCommand().equals("ALL"))
    {
      from_tf.setEnabled(false);
      to.setEnabled(false);
      to_tf.setEnabled(false);

      atts.add(new PageRanges(1, Integer.MAX_VALUE));
    }
  else
    {
      from_tf.setEnabled(true);
      to.setEnabled(true);
      to_tf.setEnabled(true);
      all_rb.setSelected(false);
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:20,代码来源:PrinterDialog.java

示例9: actionPerformed

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
public void actionPerformed(ActionEvent e)
{ 
  // if ALL is selected we must use a full-range object
  if (e.getActionCommand().equals("ALL"))
    {
      from_tf.setEnabled(false);
      to.setEnabled(false);
      to_tf.setEnabled(false);
      
      atts.add(new PageRanges(1, Integer.MAX_VALUE));
    }
  else
    {
      from_tf.setEnabled(true);
      to.setEnabled(true);
      to_tf.setEnabled(true);
      all_rb.setSelected(false);
    }       
}
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:20,代码来源:PrinterDialog.java

示例10: setRangeCopiesAttribute

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
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;
    }
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:18,代码来源:WPrinterJob.java

示例11: setAttributes

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
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);
        }
    }
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:27,代码来源:CPrinterJob.java

示例12: fillPrintRangeFields

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
void fillPrintRangeFields() {
    if (firstUse) {
        if (attrs.containsKey(PageRanges.class)) {
            PageRanges aRange = (PageRanges) (attrs.get(PageRanges.class));
            int [][] range = aRange.getMembers();
            fromTxt.setText(range.length > 0 
                    ? Integer.toString(range[0][0]) : "1");
            toTxt.setText(range.length > 0 
                    ? Integer.toString(range[0][1]) : "1");
            pageRngBtn.setSelected(true);
        } else {
            allRngBtn.setSelected(true);
            fromTxt.setEnabled(false);
            toTxt.setEnabled(false);
            fromTxt.setText("1");
            toTxt.setText("1");
            toLabel.setEnabled(false);
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:ServiceUIDialog.java

示例13: accept

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
@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;
}
 
开发者ID:Ayutac,项目名称:toolkit,代码行数:23,代码来源:PrintPanel.java

示例14: setAttributes

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
    if (attributes != null) {
        PageRanges pageRangesAttr =
            (PageRanges)attributes.get(PageRanges.class);
        if (pageRangesAttr != null) {
            SunPageSelection psel = (SunPageSelection)attributes.get(SunPageSelection.class);
            if (psel == null) {
                attributes.add(SunPageSelection.RANGE);
            }
        }
    }

    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();
    }
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:25,代码来源:CPrinterJob.java

示例15: getFromPageAttrib

import javax.print.attribute.standard.PageRanges; //导入依赖的package包/类
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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:RasterPrinterJob.java


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