Java Code Examples for java.awt.print.PrinterException#printStackTrace()
The following examples show how to use
java.awt.print.PrinterException#printStackTrace() .
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: TestMediaTraySelection.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private static void printTest() { MediaTray tray = null; //tray = getMediaTray( prservices, "Bypass Tray" ); tray = getMediaTray( prservices, "Tray 4" ); PrintRequestAttributeSet atrset = new HashPrintRequestAttributeSet(); //atrset.add( MediaSizeName.ISO_A4 ); atrset.add(tray); PrinterJob pjob = PrinterJob.getPrinterJob(); pjob.setPrintable(new TestMediaTraySelection()); try { pjob.print(atrset); } catch (PrinterException e) { e.printStackTrace(); fail(); } }
Example 2
Source File: HTMLPrintable.java From ramus with GNU General Public License v3.0 | 6 votes |
private void initRootView(final PageFormat pageFormat) { pane.setSize((int) (pageFormat.getImageableWidth() / SCALE), Integer.MAX_VALUE); pane.validate(); rootView = pane.getUI().getRootView(pane); pages.clear(); pageStartY = 0; pageEndY = 0; currentPage = -1; this.pageFormat = pageFormat; int pageIndex = 0; try { while (print(null, pageFormat, pageIndex) == PAGE_EXISTS) pageIndex++; } catch (final PrinterException e) { e.printStackTrace(); } }
Example 3
Source File: bug8023392.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); if (job.printDialog()) { try { job.print(); } catch (PrinterException ex) { ex.printStackTrace(); } } }
Example 4
Source File: PrintLatinCJKTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { try { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(testInstance); if (job.printDialog()) { job.print(); } } catch (PrinterException ex) { ex.printStackTrace(); } }
Example 5
Source File: TestUnsupportedResolution.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void printWorks(String[] args) { PrinterJob job=PrinterJob.getPrinterJob(); job.setPrintable(this); PrintRequestAttributeSet settings=new HashPrintRequestAttributeSet(); PrinterResolution pr = new PrinterResolution(300, 300, ResolutionSyntax.DPI); if (args.length > 0 && (args[0].compareTo("600") == 0)) { pr = new PrinterResolution(600, 600, ResolutionSyntax.DPI); System.out.println("Adding 600 Dpi attribute"); } else { System.out.println("Adding 300 Dpi attribute"); } PrintService ps = job.getPrintService(); boolean resolutionSupported = ps.isAttributeValueSupported(pr, null, null); System.out.println("Is "+pr+" supported by "+ps+"? "+resolutionSupported); if (resolutionSupported) { System.out.println("Resolution is supported.\nTest is not applicable, PASSED"); } settings.add(pr); if (args.length > 0 && (args[0].equalsIgnoreCase("fidelity"))) { settings.add(Fidelity.FIDELITY_TRUE); System.out.println("Adding Fidelity.FIDELITY_TRUE attribute"); } if (job.printDialog(settings)) { try { job.print(settings); } catch (PrinterException e) { e.printStackTrace(); } } }
Example 6
Source File: bug8023392.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); if (job.printDialog()) { try { job.print(); } catch (PrinterException ex) { ex.printStackTrace(); } } }
Example 7
Source File: PrintLatinCJKTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { try { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(testInstance); if (job.printDialog()) { job.print(); } } catch (PrinterException ex) { ex.printStackTrace(); } }
Example 8
Source File: BannerTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void printTest() { job.setPrintable(new BannerTest()); if(job.printDialog()) { try { job.print(); } catch (PrinterException e) { e.printStackTrace(); fail(); } } }
Example 9
Source File: LandscapeStackOverflow.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static final void main( String[] parameters ) { PrinterJob printjob = PrinterJob.getPrinterJob(); printjob.setJobName( "Test Print Job" ); PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); attributes.add( OrientationRequested.LANDSCAPE ); try { printjob.setPrintable( new Painter() ); printjob.print( attributes ); } catch( PrinterException exception ) { exception.printStackTrace(); } }
Example 10
Source File: TestCheckSystemDefaultBannerOption.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void printTest() { job.setPrintable(new TestCheckSystemDefaultBannerOption()); try { job.print(); } catch (PrinterException e) { e.printStackTrace(); } }
Example 11
Source File: bug8023392.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); if (job.printDialog()) { try { job.print(); } catch (PrinterException ex) { ex.printStackTrace(); } } }
Example 12
Source File: PrintLatinCJKTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { try { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(testInstance); if (job.printDialog()) { job.print(); } } catch (PrinterException ex) { ex.printStackTrace(); } }
Example 13
Source File: bug8023392.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); if (job.printDialog()) { try { job.print(); } catch (PrinterException ex) { ex.printStackTrace(); } } }
Example 14
Source File: PrintLatinCJKTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { try { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(testInstance); if (job.printDialog()) { job.print(); } } catch (PrinterException ex) { ex.printStackTrace(); } }
Example 15
Source File: bug8023392.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); if (job.printDialog()) { try { job.print(); } catch (PrinterException ex) { ex.printStackTrace(); } } }
Example 16
Source File: PrintLatinCJKTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { try { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(testInstance); if (job.printDialog()) { job.print(); } } catch (PrinterException ex) { ex.printStackTrace(); } }
Example 17
Source File: bug8023392.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); if (job.printDialog()) { try { job.print(); } catch (PrinterException ex) { ex.printStackTrace(); } } }
Example 18
Source File: PrintLatinCJKTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { try { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(testInstance); if (job.printDialog()) { job.print(); } } catch (PrinterException ex) { ex.printStackTrace(); } }
Example 19
Source File: PrintLatinCJKTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { try { PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(testInstance); if (job.printDialog()) { job.print(); } } catch (PrinterException ex) { ex.printStackTrace(); } }
Example 20
Source File: PrintPreviewComponent.java From ramus with GNU General Public License v3.0 | 4 votes |
@Override public void paint(Graphics gr) { super.paint(gr); Graphics2D g = (Graphics2D) gr; g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); Rectangle rect = g.getClipBounds(); int pageIndex = 0; int row = 0; int column = 0; Dimension size = getSize(); if (width * getZoom() < size.getWidth()) { g.translate((size.getWidth() - width * getZoom()) / 2, 0); } AffineTransform at = g.getTransform(); Font font = new Font("Dialog", Font.BOLD, 12); for (Page page : pages) { if (page.contains(rect, row, column)) { if (pageOf != null) { String text = MessageFormat.format( GlobalResourcesManager.getString("PageOf"), pageIndex + 1, printable.getPageCount()); if (!text.equals(pageOf.getText())) pageOf.setText(text); } g.setTransform(at); String pageNumber = "- " + (pageIndex + 1) + " -"; g.setFont(font); Rectangle2D fontRect = g.getFontMetrics().getStringBounds( pageNumber, g); double left = (pageWidth - fontRect.getWidth() - W_SPACE / zoom) / 2d; g.setColor(Color.black); g.drawString( pageNumber, (float) (left * zoom + column * (pageWidth + W_SPACE / zoom) * zoom) + 5, (float) ((pageHeight + W_SPACE / zoom) * (row + 1) * zoom) - 22); g.scale(getZoom(), getZoom()); g.translate(column * (pageWidth + W_SPACE / zoom) + 1, row * (pageHeight + W_SPACE / zoom)); Rectangle2D r = new Rectangle2D.Double(0, 0, page.width, page.height); if (reverce) g.rotate(Math.PI, r.getCenterX(), r.getCenterY()); g.setColor(Color.white); g.fill(r); g.setColor(Color.black); g.draw(r); r = new Rectangle2D.Double(page.x, page.y, page.imageableWidth, page.imageableHeight); try { g.translate(1, 1); printable.print(g, pageIndex); } catch (PrinterException e) { e.printStackTrace(); } } pageIndex++; column++; if (column >= columnCount) { column = 0; row++; } } }