我想用下面的JavaFX代码打印一个FXML页面,但是我不知道如何指示我要打印的页面。
@FXML
private void btnimprimerAction(ActionEvent event) {
final PrinterJob printerJob = PrinterJob.createPrinterJob();
if (printerJob.showPrintDialog(btnimprimer.getScene().getWindow())) {
final JobSettings settings = printerJob.getJobSettings();
final PageLayout pageLayout = settings.getPageLayout();
final double pageWidth = pageLayout.getPrintableWidth();
final double pageHeight = pageLayout.getPrintableHeight();
double pageLeftMargin = pageLayout.getLeftMargin();
double pageRightMargin = pageLayout.getRightMargin();
double pageTopMargin = pageLayout.getTopMargin();
double pageBottomMargin = pageLayout.getBottomMargin();
if (printerJob.printPage(btnimprimer)) {
printerJob.endJob();
}
}
}
我该如何解决?