javax.print.attribute.standard.Copies Java Examples
The following examples show how to use
javax.print.attribute.standard.Copies.
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: ImageableAreaTest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private static void printWithoutPrintDialog() { final JTable table = createAuthorTable(42); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); pras.add(new Copies(1)); try { boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH, new MessageFormat("Author Table"), new MessageFormat("Page - {0}"), false, pras, false); closeFrame(); if (!printAccepted) { throw new RuntimeException("User cancels the printer job!"); } } catch (Exception e) { throw new RuntimeException(e); } }
Example #2
Source File: WPrinterJob.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void setRangeCopiesAttribute(int from, int to, boolean isRangeSet, int copies) { if (attributes != null) { if (isRangeSet) { attributes.add(new PageRanges(from, to)); setPageRange(from, to); } defaultCopies = false; attributes.add(new Copies(copies)); /* Since this is called from native to tell Java to sync * up with native, we don't call this class's own setCopies() * method which is mainly to send the value down to native */ super.setCopies(copies); mAttCopies = copies; } }
Example #3
Source File: ImageableAreaTest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private static void printWithoutPrintDialog() { final JTable table = createAuthorTable(42); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); pras.add(new Copies(1)); try { boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH, new MessageFormat("Author Table"), new MessageFormat("Page - {0}"), false, pras, false); closeFrame(); if (!printAccepted) { throw new RuntimeException("User cancels the printer job!"); } } catch (Exception e) { throw new RuntimeException(e); } }
Example #4
Source File: WPrinterJob.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private final void setRangeCopiesAttribute(int from, int to, boolean isRangeSet, int copies) { if (attributes != null) { if (isRangeSet) { attributes.add(new PageRanges(from, to)); setPageRange(from, to); } defaultCopies = false; attributes.add(new Copies(copies)); /* Since this is called from native to tell Java to sync * up with native, we don't call this class's own setCopies() * method which is mainly to send the value down to native */ super.setCopies(copies); mAttCopies = copies; } }
Example #5
Source File: WPrinterJob.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private final void setRangeCopiesAttribute(int from, int to, boolean isRangeSet, int copies) { if (attributes != null) { if (isRangeSet) { attributes.add(new PageRanges(from, to)); setPageRange(from, to); } defaultCopies = false; attributes.add(new Copies(copies)); /* Since this is called from native to tell Java to sync * up with native, we don't call this class's own setCopies() * method which is mainly to send the value down to native */ super.setCopies(copies); mAttCopies = copies; } }
Example #6
Source File: WPrinterJob.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private final void setRangeCopiesAttribute(int from, int to, boolean isRangeSet, int copies) { if (attributes != null) { if (isRangeSet) { attributes.add(new PageRanges(from, to)); setPageRange(from, to); } defaultCopies = false; attributes.add(new Copies(copies)); /* Since this is called from native to tell Java to sync * up with native, we don't call this class's own setCopies() * method which is mainly to send the value down to native */ super.setCopies(copies); mAttCopies = copies; } }
Example #7
Source File: ImageableAreaTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private static void printWithoutPrintDialog() { final JTable table = createAuthorTable(42); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); pras.add(new Copies(1)); try { boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH, new MessageFormat("Author Table"), new MessageFormat("Page - {0}"), false, pras, false); closeFrame(); if (!printAccepted) { throw new RuntimeException("User cancels the printer job!"); } } catch (Exception e) { throw new RuntimeException(e); } }
Example #8
Source File: WPrinterJob.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private final void setRangeCopiesAttribute(int from, int to, boolean isRangeSet, int copies) { if (attributes != null) { if (isRangeSet) { attributes.add(new PageRanges(from, to)); setPageRange(from, to); } defaultCopies = false; attributes.add(new Copies(copies)); /* Since this is called from native to tell Java to sync * up with native, we don't call this class's own setCopies() * method which is mainly to send the value down to native */ super.setCopies(copies); mAttCopies = copies; } }
Example #9
Source File: ImageableAreaTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void printWithoutPrintDialog() { final JTable table = createAuthorTable(50); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); pras.add(new Copies(1)); try { boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH, new MessageFormat("Author Table"), new MessageFormat("Page - {0}"), false, pras, false); closeFrame(); if (!printAccepted) { throw new RuntimeException("User cancels the printer job!"); } } catch (Exception e) { throw new RuntimeException(e); } }
Example #10
Source File: ImageableAreaTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
private static void printWithoutPrintDialog() { final JTable table = createAuthorTable(42); PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); pras.add(new Copies(1)); try { boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH, new MessageFormat("Author Table"), new MessageFormat("Page - {0}"), false, pras, false); closeFrame(); if (!printAccepted) { throw new RuntimeException("User cancels the printer job!"); } } catch (Exception e) { throw new RuntimeException(e); } }
Example #11
Source File: ImageableAreaTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void printWithCustomImageareaSize() { final JTable table = createAuthorTable(18); PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet(); printAttributes.add(DialogTypeSelection.NATIVE); printAttributes.add(new Copies(1)); printAttributes.add(new MediaPrintableArea( 0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH)); Printable printable = table.getPrintable( JTable.PrintMode.NORMAL, new MessageFormat("Author Table"), new MessageFormat("Page - {0}") ); PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(printable); boolean printAccepted = job.printDialog(printAttributes); if (printAccepted) { try { job.print(printAttributes); closeFrame(); } catch (Exception e) { throw new RuntimeException(e); } } else { throw new RuntimeException("User cancels the printer job!"); } }
Example #12
Source File: Win32PrintService.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private boolean isSupportedCopies(Copies copies) { synchronized (this) { if (gotCopies == false) { nCopies = getCopiesSupported(printer, getPort()); gotCopies = true; } } int numCopies = copies.getValue(); return (numCopies > 0 && numCopies <= nCopies); }
Example #13
Source File: Win32PrintService.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private boolean isPSDocAttr(Class category) { if (category == OrientationRequested.class || category == Copies.class) { return true; } else { return false; } }
Example #14
Source File: Win32PrintService.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private boolean isSupportedCopies(Copies copies) { synchronized (this) { if (gotCopies == false) { nCopies = getCopiesSupported(printer, getPort()); gotCopies = true; } } int numCopies = copies.getValue(); return (numCopies > 0 && numCopies <= nCopies); }
Example #15
Source File: ImageableAreaTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static void printWithCustomImageareaSize() { final JTable table = createAuthorTable(18); PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet(); printAttributes.add(DialogTypeSelection.NATIVE); printAttributes.add(new Copies(1)); printAttributes.add(new MediaPrintableArea( 0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH)); Printable printable = table.getPrintable( JTable.PrintMode.NORMAL, new MessageFormat("Author Table"), new MessageFormat("Page - {0}") ); PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(printable); boolean printAccepted = job.printDialog(printAttributes); if (printAccepted) { try { job.print(printAttributes); closeFrame(); } catch (Exception e) { throw new RuntimeException(e); } } else { throw new RuntimeException("User cancels the printer job!"); } }
Example #16
Source File: Win32PrintJob.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void pageableJob(Pageable pageable) throws PrintException { try { synchronized(this) { if (job != null) { // shouldn't happen throw new PrintException("already printing"); } else { job = new sun.awt.windows.WPrinterJob(); } } PrintService svc = getPrintService(); job.setPrintService(svc); if (copies == 0) { Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class); copies = c.getValue(); } job.setCopies(copies); job.setJobName(jobName); job.setPageable(pageable); job.print(reqAttrSet); notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE); return; } catch (PrinterException pe) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(pe); } finally { printReturned = true; notifyEvent(PrintJobEvent.NO_MORE_EVENTS); } }
Example #17
Source File: Win32PrintJob.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void pageableJob(Pageable pageable) throws PrintException { try { synchronized(this) { if (job != null) { // shouldn't happen throw new PrintException("already printing"); } else { job = new sun.awt.windows.WPrinterJob(); } } PrintService svc = getPrintService(); job.setPrintService(svc); if (copies == 0) { Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class); copies = c.getValue(); } job.setCopies(copies); job.setJobName(jobName); job.setPageable(pageable); job.print(reqAttrSet); notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE); return; } catch (PrinterException pe) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(pe); } finally { printReturned = true; notifyEvent(PrintJobEvent.NO_MORE_EVENTS); } }
Example #18
Source File: Win32PrintService.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private boolean isPSDocAttr(Class category) { if (category == OrientationRequested.class || category == Copies.class) { return true; } else { return false; } }
Example #19
Source File: Win32PrintService.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private boolean isSupportedCopies(Copies copies) { synchronized (this) { if (gotCopies == false) { nCopies = getCopiesSupported(printer, getPort()); gotCopies = true; } } int numCopies = copies.getValue(); return (numCopies > 0 && numCopies <= nCopies); }
Example #20
Source File: DummyPrintTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public void print(Doc doc, PrintRequestAttributeSet printRequestAttributeSet) throws PrintException { System.out.println("job name: " + printRequestAttributeSet.get(JobName.class)); System.out.println("copies: " + printRequestAttributeSet.get(Copies.class)); if(printRequestAttributeSet.get(JobName.class) == null || printRequestAttributeSet.get(Copies.class) == null) { throw new RuntimeException("Copies and JobName is not passed correctly"); } }
Example #21
Source File: Win32PrintService.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private boolean isSupportedCopies(Copies copies) { synchronized (this) { if (gotCopies == false) { nCopies = getCopiesSupported(printer, getPort()); gotCopies = true; } } int numCopies = copies.getValue(); return (numCopies > 0 && numCopies <= nCopies); }
Example #22
Source File: PrintDlgApp.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Starts the application. */ public static void main(java.lang.String[] args) { PrintDlgApp pd = new PrintDlgApp(); PrinterJob pj = PrinterJob.getPrinterJob(); System.out.println(pj); PrintRequestAttributeSet pSet = new HashPrintRequestAttributeSet(); pSet.add(new Copies(1)); //PageFormat pf = pj.pageDialog(pSet); PageFormat pf = new PageFormat(); System.out.println("Setting Printable...pf = "+pf); if (pf == null) { return; } pj.setPrintable(pd,pf); //try { pj.setPrintService(services[0]); } catch(Exception e) { e.printStackTrace(); } pSet.add(new Destination(new java.io.File("./out.prn").toURI())); System.out.println("open PrintDialog.."); for (int i=0; i<2; i++) { if (pj.printDialog(pSet)) { try { System.out.println("About to print the data ..."); pj.print(pSet); System.out.println("Printed"); } catch (PrinterException pe) { pe.printStackTrace(); } } } }
Example #23
Source File: Win32PrintService.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private boolean isSupportedCopies(Copies copies) { synchronized (this) { if (gotCopies == false) { nCopies = getCopiesSupported(printer, getPort()); gotCopies = true; } } int numCopies = copies.getValue(); return (numCopies > 0 && numCopies <= nCopies); }
Example #24
Source File: Win32PrintService.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private boolean isPSDocAttr(Class category) { if (category == OrientationRequested.class || category == Copies.class) { return true; } else { return false; } }
Example #25
Source File: Win32PrintJob.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void pageableJob(Pageable pageable) throws PrintException { try { synchronized(this) { if (job != null) { // shouldn't happen throw new PrintException("already printing"); } else { job = new sun.awt.windows.WPrinterJob(); } } PrintService svc = getPrintService(); job.setPrintService(svc); if (copies == 0) { Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class); copies = c.getValue(); } job.setCopies(copies); job.setJobName(jobName); job.setPageable(pageable); job.print(reqAttrSet); notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE); return; } catch (PrinterException pe) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(pe); } finally { printReturned = true; notifyEvent(PrintJobEvent.NO_MORE_EVENTS); } }
Example #26
Source File: Win32PrintJob.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void pageableJob(Pageable pageable) throws PrintException { try { synchronized(this) { if (job != null) { // shouldn't happen throw new PrintException("already printing"); } else { job = new sun.awt.windows.WPrinterJob(); } } PrintService svc = getPrintService(); job.setPrintService(svc); if (copies == 0) { Copies c = (Copies)svc.getDefaultAttributeValue(Copies.class); copies = c.getValue(); } job.setCopies(copies); job.setJobName(jobName); job.setPageable(pageable); job.print(reqAttrSet); notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE); return; } catch (PrinterException pe) { notifyEvent(PrintJobEvent.JOB_FAILED); throw new PrintException(pe); } finally { printReturned = true; notifyEvent(PrintJobEvent.NO_MORE_EVENTS); } }
Example #27
Source File: ImageableAreaTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void printWithCustomImageareaSize() { final JTable table = createAuthorTable(18); PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet(); printAttributes.add(DialogTypeSelection.NATIVE); printAttributes.add(new Copies(1)); printAttributes.add(new MediaPrintableArea( 0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH)); Printable printable = table.getPrintable( JTable.PrintMode.NORMAL, new MessageFormat("Author Table"), new MessageFormat("Page - {0}") ); PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(printable); boolean printAccepted = job.printDialog(printAttributes); if (printAccepted) { try { job.print(printAttributes); closeFrame(); } catch (Exception e) { throw new RuntimeException(e); } } else { throw new RuntimeException("User cancels the printer job!"); } }
Example #28
Source File: Win32PrintService.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private boolean isPSDocAttr(Class category) { if (category == OrientationRequested.class || category == Copies.class) { return true; } else { return false; } }
Example #29
Source File: Win32PrintService.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private boolean isSupportedCopies(Copies copies) { synchronized (this) { if (gotCopies == false) { nCopies = getCopiesSupported(printer, getPort()); gotCopies = true; } } int numCopies = copies.getValue(); return (numCopies > 0 && numCopies <= nCopies); }
Example #30
Source File: ImageableAreaTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void printWithCustomImageareaSize() { final JTable table = createAuthorTable(18); PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet(); printAttributes.add(DialogTypeSelection.NATIVE); printAttributes.add(new Copies(1)); printAttributes.add(new MediaPrintableArea( 0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH)); Printable printable = table.getPrintable( JTable.PrintMode.NORMAL, new MessageFormat("Author Table"), new MessageFormat("Page - {0}") ); PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(printable); boolean printAccepted = job.printDialog(printAttributes); if (printAccepted) { try { job.print(printAttributes); closeFrame(); } catch (Exception e) { throw new RuntimeException(e); } } else { throw new RuntimeException("User cancels the printer job!"); } }