Java Code Examples for java.awt.Toolkit#getPrintJob()
The following examples show how to use
java.awt.Toolkit#getPrintJob() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobAttrUpdateTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void printTest() { JobAttributes ja = new JobAttributes(); Toolkit tk = Toolkit.getDefaultToolkit(); // ja.setToPage(4); // ja.setFromPage(3); // show dialog PrintJob pjob = tk.getPrintJob(new JFrame(), "test", ja, null); if (pjob == null) { return; } if (ja.getDefaultSelection() == JobAttributes.DefaultSelectionType.RANGE) { int fromPage = ja.getFromPage(); int toPage = ja.getToPage(); if (fromPage != 2 || toPage != 3) { fail(); } else { pass(); } } }
Example 2
Source File: PrinterException.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Robot robot = new Robot(); Thread t = new Thread (() -> { robot.waitForIdle(); robot.delay(2000); robot.keyPress(KeyEvent.VK_ESCAPE); robot.keyRelease(KeyEvent.VK_ESCAPE); }); Toolkit tk = Toolkit.getDefaultToolkit(); PrintJob pj = null; int[][] pageRange = new int[][]{new int[]{1,1}}; JobAttributes ja = new JobAttributes(1, java.awt.JobAttributes.DefaultSelectionType.ALL, JobAttributes.DestinationType.FILE, JobAttributes.DialogType.NATIVE, "filename.ps", Integer.MAX_VALUE, 1, JobAttributes.MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES, pageRange, "", JobAttributes.SidesType.ONE_SIDED); Frame testFrame = new Frame("print"); try { if (tk != null) { t.start(); pj = tk.getPrintJob(testFrame, null, ja, null); } } finally { testFrame.dispose(); } }
Example 3
Source File: PrintTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void printTest() { JobAttributes job = new JobAttributes(); PageAttributes page = new PageAttributes(); job.setDialog(JobAttributes.DialogType.NATIVE); job.setDefaultSelection(JobAttributes.DefaultSelectionType.ALL); job.setFromPage(2); job.setToPage(5); Toolkit tk = Toolkit.getDefaultToolkit(); // setting this dialog to native printdialog if (tk != null) { PrintJob pj = tk.getPrintJob(new JFrame(), "testing the attribute setting ", job, page); } }