privatestatic Frame createInstructionUI() { final String instruction = """ This test requires that you have a printer.
Press Cancel if your system has only virtual printers such as
Microsoft Print to PDF or Microsoft XPS Document Writer since
they don't allow setting copies to anything but 1.
If a real printer is installed, select it from the drop-down
list in the Print dialog and increase the number of copies,
then press OK button.""";
TextArea instructionTextArea = new TextArea(instruction);
instructionTextArea.setEditable(false);
publicstaticvoid showPrintDialog() {
PrinterJob job = PrinterJob.getPrinterJob(); if (job.getPrintService() == null) {
System.out.println("Looks like printer is not configured. Please install printer " + " and re-run the test case."); return;
}
checkNoOfCopies(job, job.printDialog());
}
publicstaticvoid checkNoOfCopies(PrinterJob job, boolean pdReturnValue) { if (pdReturnValue) {
System.out.println("User has selected OK/Print button on the PrintDialog"); int copies = job.getCopies(); if (copies <= 1) { thrownew RuntimeException("Expected the number of copies to be more than 1 but got " + copies);
} else {
System.out.println("Total number of copies : " + copies);
}
} else {
System.out.println("User has selected Cancel button on the PrintDialog.");
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.