List of usage examples for java.awt.print PrinterJob getPrinterJob
public static PrinterJob getPrinterJob()
From source file:org.gvsig.remotesensing.scatterplot.chart.ScatterPlotDiagram.java
/** * Creates a print job for the chart.// ww w.j a v a 2 s . co m */ 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); } } } }
From source file:org.gumtree.vis.awt.JChartPanel.java
@Override public void createChartPrintJob() { setCursor(WAIT_CURSOR);/*from ww w. j a v a 2 s . c om*/ PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); try { job.print(); } catch (PrinterException e) { JOptionPane.showMessageDialog(this, e); } finally { setCursor(defaultCursor); } } setCursor(defaultCursor); }
From source file:com.sshtools.sshterm.SshTerminalPanel.java
public void printScreen() { try {/*ww w .j a v a2s .c o m*/ PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(terminal, pageFormat); if (job.printDialog()) { setCursor(Cursor.getPredefinedCursor(3)); job.print(); setCursor(Cursor.getPredefinedCursor(0)); } } catch (PrinterException pe) { JOptionPane.showMessageDialog(this, pe.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }
From source file:org.mwc.cmap.grideditor.chart.FixedChartComposite.java
/** * Creates a print job for the chart./* ww w . j a v a 2 s . co m*/ */ public void createChartPrintJob() { // FIXME try to replace swing print stuff by swt final PrinterJob job = PrinterJob.getPrinterJob(); final PageFormat pf = job.defaultPage(); final PageFormat pf2 = job.pageDialog(pf); if (pf2 != pf) { job.setPrintable(this, pf2); if (job.printDialog()) { try { job.print(); } catch (final PrinterException e) { final MessageBox messageBox = new MessageBox(this.canvas.getShell(), SWT.OK | SWT.ICON_ERROR); messageBox.setMessage(e.getMessage()); messageBox.open(); } } } }
From source file:rulebender.editors.dat.view.CustomizedChartComposite.java
/** * Creates a print job for the chart.//from www . ja va 2 s .c o m */ 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(); } } } }
From source file:com.rcp.wbw.demo.ChartComposite.java
/** * Creates a print job for the chart./*from w w w . ja va2 s . co m*/ */ 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(); } } } }
From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java
/** * @param actionableTree/*w w w . jav a2 s. co m*/ */ public void print(final JTree actionableTree) { /*if (true) { PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(OrientationRequested.LANDSCAPE); aset.add(new Copies(2)); aset.add(new JobName("My job", null)); // Create a print job PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPrintable(this); // locate a print service that can handle the request PrintService[] services = PrinterJob.lookupPrintServices(); if (services.length > 0) { System.out.println("selected printer " + services[0].getName()); try { pj.setPrintService(services[0]); pj.pageDialog(aset); if(pj.printDialog(aset)) { pj.print(aset); } } catch (PrinterException pe) { System.err.println(pe); } } return; }*/ DefaultMutableTreeNode clonedTree = GhostActionableTree .makeDeepCopy((DefaultMutableTreeNode) actionableTree.getModel().getRoot()); GhostActionableTree printTree = new GhostActionableTree(this, new DefaultTreeModel(clonedTree)); printTree.setRowHeight(ROW_HEIGHT); //printTree.setEditable(false); //printTree.setVisibleRowCount(15); ContainerTreeRenderer renderer = new ContainerTreeRenderer(null, false, false); renderer.setBGColor(Color.WHITE); renderer.setFont(getFont().deriveFont(8.0f)); //renderer.setLeafIcon(IconManager.getIcon(CollectionObject.class.getSimpleName(), IconManager.IconSize.Std32)); //renderer.setVerticalTextPosition(SwingConstants.CENTER); printTree.setCellRenderer(renderer); for (int row = 0; row < printTree.getRowCount(); row++) { printTree.expandRow(row); } PrintablePanel p = new PrintablePanel(new BorderLayout(), printTree); p.add(printTree, BorderLayout.CENTER); PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); //PrinterResolution pr = new PrinterResolution(300, 300, PrinterResolution.DPI); //MediaPrintableArea mpa = new MediaPrintableArea(8,21, 210-16, 296-42, MediaPrintableArea.MM); //aset.add( MediaSizeName.IS); //aset.add( pr ); //aset.add( mpa ); aset.add(new Copies(1)); aset.add(OrientationRequested.PORTRAIT); aset.add(PrintQuality.HIGH); PrinterJob job = PrinterJob.getPrinterJob(); /*PageFormat pageFormat = job.defaultPage(); Paper paper = pageFormat.getPaper(); paper.setSize(pageFormat.getWidth(), pageFormat.getHeight()); paper.setImageableArea( 0, 0, pageFormat.getWidth(), pageFormat.getHeight() ); //aset.add( Fidelity.FIDELITY_TRUE ); pageFormat.setPaper(paper); Book book = new Book(); book.append(p, pageFormat, 1); job.setPageable(book);*/ job.setPrintable(p); boolean ok = job.printDialog(); if (ok) { try { job.print(aset); } catch (PrinterException ex) { ex.printStackTrace(); /* The job did not successfully complete */ } } }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Creates a print job for the chart.//from ww w . j av a 2 s. co m */ public void createChartPrintJob() { PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); pf.setOrientation(PageFormat.LANDSCAPE); 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); } } } }
From source file:com.rapidminer.gui.plotter.charts.AbstractChartPanel.java
/** * Creates a print job for the chart.// ww w . java 2s. c om */ @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); } } } }
From source file:gda.plots.SimplePlot.java
/** * This overrides the method in ChartPanel which seems to behave slightly differently. The replacement may be * unecessary -investigate./*from w w w .ja v a 2 s.co m*/ */ @Override public void createChartPrintJob() { PrinterJob printerJob = PrinterJob.getPrinterJob(); PageFormat pageFormat = printerJob.defaultPage(); pageFormat.setOrientation(PageFormat.LANDSCAPE); printerJob.setPrintable(this, pageFormat); try { if (printerJob.printDialog()) { printerJob.print(); } } catch (PrinterException pe) { logger.error("Caught PrinterException: " + pe.getMessage()); } }