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


Java JobAttributes.getDialog方法代码示例

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


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

示例1: initPrintJob2D

import java.awt.JobAttributes; //导入方法依赖的package包/类
private void initPrintJob2D(Frame frame,  String doctitle,
                            JobAttributes jobAttributes,
                            PageAttributes pageAttributes) {

    SecurityManager security = System.getSecurityManager();
    if (security != null) {
        security.checkPrintJobAccess();
    }

    if (frame == null &&
        (jobAttributes == null ||
         jobAttributes.getDialog() == DialogType.NATIVE)) {
        throw new NullPointerException("Frame must not be null");
    }
    this.frame = frame;

    this.docTitle = (doctitle == null) ? "" : doctitle;
    this.jobAttributes = (jobAttributes != null)
        ? jobAttributes : new JobAttributes();
    this.pageAttributes = (pageAttributes != null)
        ? pageAttributes : new PageAttributes();

    // Currently, we always reduce page ranges to xxx or xxx-xxx
    int[][] pageRanges = this.jobAttributes.getPageRanges();
    int first = pageRanges[0][0];
    int last = pageRanges[pageRanges.length - 1][1];
    this.jobAttributes.setPageRanges(new int[][] {
        new int[] { first, last }
    });
    this.jobAttributes.setToPage(last);
    this.jobAttributes.setFromPage(first);


    // Verify that the cross feed and feed resolutions are the same
    int[] res = this.pageAttributes.getPrinterResolution();
    if (res[0] != res[1]) {
        throw new IllegalArgumentException("Differing cross feed and feed"+
                                           " resolutions not supported.");
    }

    // Verify that the app has access to the file system
    DestinationType dest= this.jobAttributes.getDestination();
    if (dest == DestinationType.FILE) {
        throwPrintToFile();

        // check if given filename is valid
        String destStr = jobAttributes.getFileName();
        if ((destStr != null) &&
            (jobAttributes.getDialog() == JobAttributes.DialogType.NONE)) {

            File f = new File(destStr);
            try {
                // check if this is a new file and if filename chars are valid
                // createNewFile returns false if file exists
                if (f.createNewFile()) {
                    f.delete();
                }
            } catch (IOException ioe) {
                throw new IllegalArgumentException("Cannot write to file:"+
                                                   destStr);
            } catch (SecurityException se) {
                //There is already file read/write access so at this point
                // only delete access is denied.  Just ignore it because in
                // most cases the file created in createNewFile gets overwritten
                // anyway.
            }

             File pFile = f.getParentFile();
             if ((f.exists() &&
                  (!f.isFile() || !f.canWrite())) ||
                 ((pFile != null) &&
                  (!pFile.exists() || (pFile.exists() && !pFile.canWrite())))) {
                 throw new IllegalArgumentException("Cannot write to file:"+
                                                    destStr);
             }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:79,代码来源:PrintJob2D.java


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