我想在打印之前显示一个对话框,以便用户可以选择自己喜欢的打印机,并在可能的情况下更改页面设置,
我在桌面环境(Windows 8 64位)中使用Java 8 update 31,我当前的代码是这样的

Node node = new Circle(100, 200, 200);
PrinterJob job = PrinterJob.createPrinterJob();
if (job != null) {
boolean success = job.printPage(node);
if (success) {
    job.endJob();
}
}

最佳答案

您可以使用PrinterJob的showPrintDialog方法。

PrinterJob job = PrinterJob.createPrinterJob();
if (job != null && job.showPrintDialog(node.getScene().getWindow())){
    boolean success = job.printPage(node);
    if (success) {
        job.endJob();
    }
}

08-28 21:31