java.awt.Toolkit#getPrintJob ( )源码实例Demo

下面列出了java.awt.Toolkit#getPrintJob ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk9   文件: JobAttrUpdateTest.java
private static void printTest() {
    JobAttributes ja = new JobAttributes();

    Toolkit tk = Toolkit.getDefaultToolkit();
    // ja.setToPage(4);
    // ja.setFromPage(3);
    // show dialog
    PrintJob pjob = tk.getPrintJob(new JFrame(), "test", ja, null);
    if (pjob == null) {
        return;
    }


    if (ja.getDefaultSelection() == JobAttributes.DefaultSelectionType.RANGE) {
        int fromPage = ja.getFromPage();
        int toPage = ja.getToPage();
        if (fromPage != 2 || toPage != 3) {
            fail();
        } else {
            pass();
        }
    }
}
 
源代码2 项目: openjdk-jdk9   文件: PrinterException.java
public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    Thread t = new Thread (() -> {
        robot.waitForIdle();
        robot.delay(2000);
        robot.keyPress(KeyEvent.VK_ESCAPE);
        robot.keyRelease(KeyEvent.VK_ESCAPE);
       });
    Toolkit tk = Toolkit.getDefaultToolkit();
    PrintJob pj = null;

    int[][] pageRange = new int[][]{new int[]{1,1}};
    JobAttributes ja = new JobAttributes(1,
            java.awt.JobAttributes.DefaultSelectionType.ALL,
            JobAttributes.DestinationType.FILE, JobAttributes.DialogType.NATIVE,
            "filename.ps", Integer.MAX_VALUE, 1,
            JobAttributes.MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,
             pageRange, "", JobAttributes.SidesType.ONE_SIDED);

    Frame testFrame = new Frame("print");
    try {
        if (tk != null) {
            t.start();
            pj = tk.getPrintJob(testFrame, null, ja, null);
        }
    } finally {
        testFrame.dispose();
    }
}
 
源代码3 项目: openjdk-jdk9   文件: PrintTest.java
private static void printTest() {
    JobAttributes job = new JobAttributes();
    PageAttributes page = new PageAttributes();
    job.setDialog(JobAttributes.DialogType.NATIVE);
    job.setDefaultSelection(JobAttributes.DefaultSelectionType.ALL);
    job.setFromPage(2);
    job.setToPage(5);
    Toolkit tk = Toolkit.getDefaultToolkit();
    // setting this dialog to native printdialog
    if (tk != null) {
        PrintJob pj = tk.getPrintJob(new JFrame(),
                      "testing the attribute setting ", job, page);
    }
}