java如何在FXML中打印所选窗格
我想打印fxml包含窗格,但不知道如何打印。 我尝试了两个按钮动作代码
first
void doPrint(Node printPane) {
PrinterJob job = PrinterJob.createPrinterJob();
if (job != null && job.showPageSetupDialog(printPane.getScene().getWindow())) {
job.printPage(printPane);
job.endJob();
}
}
}
second
boolean doPrint(Node printPane) {
PrinterJob job = PrinterJob.createPrinterJob();
if (job == null) {
return false;
}
if (!job.printPage(printPane)) {
return false;
}
return job.endJob();
}
# 1 楼答案
试试这个动作事件
}
使用窗格的fx:id,而不是tab\u doctor\u list
# 2 楼答案
这将打印您传递到其中的任何节点