PageDialogMarginTest.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:openjdk-jdk10 作者:
public static void main(String args[]) throws Exception {
    String[] instructions
            = {
                "Page Dialog will be shown.",
                "Change top(in) margin value from 1.0 to 2.0",
                "Then select OK."
            };
    SwingUtilities.invokeAndWait(() -> {
        JOptionPane.showMessageDialog((Component) null,
                instructions, "Instructions",
                JOptionPane.INFORMATION_MESSAGE);
    });
    PrinterJob pj = PrinterJob.getPrinterJob();
    try {
        HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        PageFormat pf;
        pf = pj.pageDialog(aset);
        double left = pf.getImageableX();
        double top = pf.getImageableY();
        System.out.println("pageDialog - left/top from pageFormat: " + left / 72
                + " " + top / 72);
        System.out.println("pageDialog - left/top from attribute set: "
                + getPrintableXFromASet(aset) + " "
                + getPrintableYFromASet(aset));
        if (top / 72 != 2.0f || getPrintableYFromASet(aset) != 2.0f) {
            throw new RuntimeException("Top margin value not updated");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号