Reputation: 23
I'd like to show a dialog prior to printing so that users can choose their preferred printer and also change page setup if possible, I'm using Java 8 update 31 in a desktop environment (Windows 8 64 bit), my current code like this
Node node = new Circle(100, 200, 200);
PrinterJob job = PrinterJob.createPrinterJob();
if (job != null) {
boolean success = job.printPage(node);
if (success) {
job.endJob();
}
}
Upvotes: 2
Views: 9443
Reputation: 36742
You can use the showPrintDialog method of PrinterJob.
PrinterJob job = PrinterJob.createPrinterJob();
if (job != null && job.showPrintDialog(node.getScene().getWindow())){
boolean success = job.printPage(node);
if (success) {
job.endJob();
}
}
Upvotes: 11