Java Code Examples for java.awt.print.PrinterJob#pageDialog()
The following examples show how to use
java.awt.print.PrinterJob#pageDialog() .
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: PageDlgApp.java From TencentKona-8 with GNU General Public License v2.0 | 7 votes |
public static void main(String[] args) throws Exception { String[] instructions = { "Visual inspection of the dialog is needed. ", "It should be a Printer Job Setup Dialog", "Do nothing except Cancel", "You must NOT press OK", }; SwingUtilities.invokeAndWait(() -> { JOptionPane.showMessageDialog( (Component) null, instructions, "information", JOptionPane.INFORMATION_MESSAGE); }); PrinterJob pj = PrinterJob.getPrinterJob(); PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); pSet.add(DialogTypeSelection.NATIVE); if ((pj.pageDialog(pSet)) != null) { throw new RuntimeException("PrinterJob.pageDialog(PrintRequestAttributeSet)" + " does not return null when dialog is cancelled"); } }
Example 2
Source File: PageDlgApp.java From openjdk-jdk8u with GNU General Public License v2.0 | 7 votes |
public static void main(String[] args) throws Exception { String[] instructions = { "Visual inspection of the dialog is needed. ", "It should be a Printer Job Setup Dialog", "Do nothing except Cancel", "You must NOT press OK", }; SwingUtilities.invokeAndWait(() -> { JOptionPane.showMessageDialog( (Component) null, instructions, "information", JOptionPane.INFORMATION_MESSAGE); }); PrinterJob pj = PrinterJob.getPrinterJob(); PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); pSet.add(DialogTypeSelection.NATIVE); if ((pj.pageDialog(pSet)) != null) { throw new RuntimeException("PrinterJob.pageDialog(PrintRequestAttributeSet)" + " does not return null when dialog is cancelled"); } }
Example 3
Source File: ChartComposite.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a print job for the chart. */ public void createChartPrintJob() { //FIXME try to replace swing print stuff by swt PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { MessageBox messageBox = new MessageBox( this.canvas.getShell(), SWT.OK | SWT.ICON_ERROR); messageBox.setMessage(e.getMessage()); messageBox.open(); } } } }
Example 4
Source File: PageDlgApp.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String[] instructions = { "Visual inspection of the dialog is needed. ", "It should be a Printer Job Setup Dialog", "Do nothing except Cancel", "You must NOT press OK", }; SwingUtilities.invokeAndWait(() -> { JOptionPane.showMessageDialog( (Component) null, instructions, "information", JOptionPane.INFORMATION_MESSAGE); }); PrinterJob pj = PrinterJob.getPrinterJob(); PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); pSet.add(DialogTypeSelection.NATIVE); if ((pj.pageDialog(pSet)) != null) { throw new RuntimeException("PrinterJob.pageDialog(PrintRequestAttributeSet)" + " does not return null when dialog is cancelled"); } }
Example 5
Source File: AbstractChartPanel.java From rapidminer-studio with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates a print job for the chart. */ @Override public void createChartPrintJob() { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { JOptionPane.showMessageDialog(this, e); } } } }
Example 6
Source File: ChartPanel.java From opensim-gui with Apache License 2.0 | 6 votes |
/** * Creates a print job for the chart. Prints to printer */ public void createChartPrintJob() { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { printToPrinter=true; job.print(); } catch (PrinterException e) { JOptionPane.showMessageDialog(this, e); } } } }
Example 7
Source File: ChartComposite.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a print job for the chart. */ public void createChartPrintJob() { //FIXME try to replace swing print stuff by swt PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { MessageBox messageBox = new MessageBox( this.canvas.getShell(), SWT.OK | SWT.ICON_ERROR ); messageBox.setMessage( e.getMessage() ); messageBox.open(); } } } }
Example 8
Source File: ChartPanel.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a print job for the chart. */ public void createChartPrintJob() { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { JOptionPane.showMessageDialog(this, e); } } } }
Example 9
Source File: ChartPanel.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a print job for the chart. */ public void createChartPrintJob() { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { JOptionPane.showMessageDialog(this, e); } } } }
Example 10
Source File: PageDlgApp.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { String[] instructions = { "Visual inspection of the dialog is needed. ", "It should be a Printer Job Setup Dialog", "Do nothing except Cancel", "You must NOT press OK", }; SwingUtilities.invokeAndWait(() -> { JOptionPane.showMessageDialog( (Component) null, instructions, "information", JOptionPane.INFORMATION_MESSAGE); }); PrinterJob pj = PrinterJob.getPrinterJob(); PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); pSet.add(DialogTypeSelection.NATIVE); if ((pj.pageDialog(pSet)) != null) { throw new RuntimeException("PrinterJob.pageDialog(PrintRequestAttributeSet)" + " does not return null when dialog is cancelled"); } }
Example 11
Source File: ChartPanel.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Creates a print job for the chart. */ public void createChartPrintJob() { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { JOptionPane.showMessageDialog(this, e); } } } }
Example 12
Source File: ChartPanel.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Creates a print job for the chart. */ public void createChartPrintJob() { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (PrinterException e) { JOptionPane.showMessageDialog(this, e); } } } }
Example 13
Source File: PrintSettings.java From netbeans with Apache License 2.0 | 5 votes |
/** * @return <tt>null</tt> Shows pageDialog, however. */ public java.awt.Component getCustomEditor() { PageFormat pf = (PageFormat) getValue(); PrinterJob pj = PrinterJob.getPrinterJob(); PageFormat npf = pj.pageDialog(pf); //setValue(npf); (PrintSettings.findObject(PrintSettings.class)).setPageFormat((PageFormat) npf.clone()); pj.cancel(); return null; }
Example 14
Source File: PageDlgPrnButton.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void pageDialogExample() throws PrinterException { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat originalPageFormat = job.defaultPage(); PageFormat pageFormat = job.pageDialog(originalPageFormat); if(originalPageFormat == pageFormat) return; job.setPrintable(this,pageFormat); job.print(); }
Example 15
Source File: PageDlgStackOverflowTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) { PrinterJob job = PrinterJob.getPrinterJob(); if (job == null) { return; } PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); pSet.add(DialogTypeSelection.NATIVE); job.printDialog(pSet); try { job.pageDialog(pSet); } catch (StackOverflowError e) { throw new RuntimeException("StackOverflowError is thrown"); } }
Example 16
Source File: PageDlgStackOverflowTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) { PrinterJob job = PrinterJob.getPrinterJob(); if (job == null) { return; } PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); pSet.add(DialogTypeSelection.NATIVE); job.printDialog(pSet); try { job.pageDialog(pSet); } catch (StackOverflowError e) { throw new RuntimeException("StackOverflowError is thrown"); } }
Example 17
Source File: PageDlgStackOverflowTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) { PrinterJob job = PrinterJob.getPrinterJob(); if (job == null) { return; } PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); pSet.add(DialogTypeSelection.NATIVE); job.printDialog(pSet); try { job.pageDialog(pSet); } catch (StackOverflowError e) { throw new RuntimeException("StackOverflowError is thrown"); } }
Example 18
Source File: PageDialogMarginValidation.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void pageMarginTest() { PrinterJob pj = PrinterJob.getPrinterJob(); HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); PageFormat pf; pf = pj.pageDialog(aset); }
Example 19
Source File: PrinterAttributesPanel.java From tn5250j with GNU General Public License v2.0 | 3 votes |
private void getLandscapeAttributes() { PrinterJob printJob = PrinterJob.getPrinterJob(); PageFormat documentPageFormat = new PageFormat(); documentPageFormat.setOrientation(PageFormat.LANDSCAPE); documentPageFormat.setPaper(pappyLand); documentPageFormat = printJob.pageDialog(documentPageFormat); pappyLand = documentPageFormat.getPaper(); }
Example 20
Source File: PrinterAttributesPanel.java From tn5250j with GNU General Public License v2.0 | 3 votes |
private void getPortraitAttributes() { PrinterJob printJob = PrinterJob.getPrinterJob(); PageFormat documentPageFormat = new PageFormat(); documentPageFormat.setOrientation(PageFormat.PORTRAIT); documentPageFormat.setPaper(pappyPort); documentPageFormat = printJob.pageDialog(documentPageFormat); pappyPort = documentPageFormat.getPaper(); }