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

项目:openjdk-jdk10    文件:PageDlgApp.java   
public static void main(String[] args) throws Exception {

        String[] instructions =
         {
             "Visual inspection of the dialog is needed. ",
             "It should be a Printer Job Setup Dialog",
             "Do nothing except Cancel",
             "You must NOT press OK",
         };
        SwingUtilities.invokeAndWait(() -> {
            JOptionPane.showMessageDialog(
                    (Component) null,
                    instructions,
                    "information", JOptionPane.INFORMATION_MESSAGE);
        });
        PrinterJob pj = PrinterJob.getPrinterJob();
        PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet();
        pSet.add(DialogTypeSelection.NATIVE);
        if ((pj.pageDialog(pSet)) != null) {
            throw
            new RuntimeException("PrinterJob.pageDialog(PrintRequestAttributeSet)"
                        + " does not return null when dialog is cancelled");
        }
    }
项目:openjdk-jdk10    文件:PrintAttributeUpdateTest.java   
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);
}
项目:openjdk9    文件:PageDlgApp.java   
public static void main(String[] args) throws Exception {

        String[] instructions =
         {
             "Visual inspection of the dialog is needed. ",
             "It should be a Printer Job Setup Dialog",
             "Do nothing except Cancel",
             "You must NOT press OK",
         };
        SwingUtilities.invokeAndWait(() -> {
            JOptionPane.showMessageDialog(
                    (Component) null,
                    instructions,
                    "information", JOptionPane.INFORMATION_MESSAGE);
        });
        PrinterJob pj = PrinterJob.getPrinterJob();
        PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet();
        pSet.add(DialogTypeSelection.NATIVE);
        if ((pj.pageDialog(pSet)) != null) {
            throw
            new RuntimeException("PrinterJob.pageDialog(PrintRequestAttributeSet)"
                        + " does not return null when dialog is cancelled");
        }
    }
项目:openjdk9    文件:PrintAttributeUpdateTest.java   
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);
}
项目:jdk8u_jdk    文件:PageDlgApp.java   
public static void main(String[] args) throws Exception {

        String[] instructions =
         {
             "Visual inspection of the dialog is needed. ",
             "It should be a Printer Job Setup Dialog",
             "Do nothing except Cancel",
             "You must NOT press OK",
         };
        SwingUtilities.invokeAndWait(() -> {
            JOptionPane.showMessageDialog(
                    (Component) null,
                    instructions,
                    "information", JOptionPane.INFORMATION_MESSAGE);
        });
        PrinterJob pj = PrinterJob.getPrinterJob();
        PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet();
        pSet.add(DialogTypeSelection.NATIVE);
        if ((pj.pageDialog(pSet)) != null) {
            throw
            new RuntimeException("PrinterJob.pageDialog(PrintRequestAttributeSet)"
                        + " does not return null when dialog is cancelled");
        }
    }
项目:jdk8u_jdk    文件:PrintAttributeUpdateTest.java   
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);
}
项目: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    文件: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    文件:PrintDlgPageable.java   
private static void printTest() {
    PrinterJob pj = PrinterJob.getPrinterJob();
    PageableHandler handler = new PageableHandler();
    pj.setPageable(handler);

    PrintRequestAttributeSet pSet =  new HashPrintRequestAttributeSet();
    pSet.add(DialogTypeSelection.COMMON);
    pj.printDialog(pSet);
}
项目:openjdk-jdk10    文件:DlgAttrsBug.java   
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);
}
项目:openjdk-jdk10    文件:PageDlgStackOverflowTest.java   
public static void main(String args[]) {
    PrinterJob job = PrinterJob.getPrinterJob();
    if (job == null) {
        return;
    }
    PrintRequestAttributeSet pSet =
         new HashPrintRequestAttributeSet();
    pSet.add(DialogTypeSelection.NATIVE);
    job.printDialog(pSet);
    try {
        job.pageDialog(pSet);
    } catch (StackOverflowError e) {
        throw new RuntimeException("StackOverflowError is thrown");
    }
}
项目:openjdk9    文件: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!");
    }
}
项目:openjdk9    文件:DlgAttrsBug.java   
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);
}
项目:openjdk9    文件:PageDlgStackOverflowTest.java   
public static void main(String args[]) {
    PrinterJob job = PrinterJob.getPrinterJob();
    if (job == null) {
        return;
    }
    PrintRequestAttributeSet pSet =
         new HashPrintRequestAttributeSet();
    pSet.add(DialogTypeSelection.NATIVE);
    job.printDialog(pSet);
    try {
        job.pageDialog(pSet);
    } catch (StackOverflowError e) {
        throw new RuntimeException("StackOverflowError is thrown");
    }
}
项目: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!");
    }
}
项目:jdk8u_jdk    文件:PageDlgStackOverflowTest.java   
public static void main(String args[]) {
    PrinterJob job = PrinterJob.getPrinterJob();
    if (job == null) {
        return;
    }
    PrintRequestAttributeSet pSet =
         new HashPrintRequestAttributeSet();
    pSet.add(DialogTypeSelection.NATIVE);
    job.printDialog(pSet);
    try {
        job.pageDialog(pSet);
    } catch (StackOverflowError e) {
        throw new RuntimeException("StackOverflowError is thrown");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件: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!");
    }
}