use of java.awt.print.PrinterException in project OpenNotebook by jaltekruse.
the class NotebookPanel method print.
public void print() {
DocPrinter docPrinter = new DocPrinter();
docPrinter.setDoc(getCurrentDocViewer().getDoc());
PrinterJob job = PrinterJob.getPrinterJob();
Paper paper = new Paper();
Document doc = getCurrentDocViewer().getDoc();
paper.setImageableArea(doc.getxMargin(), doc.getyMargin(), doc.getWidth() - 2 * doc.getxMargin(), doc.getHeight() - 2 * doc.getyMargin());
paper.setSize(doc.getWidth(), doc.getHeight());
PageFormat pf = job.defaultPage();
pf.setPaper(paper);
job.setPrintable(docPrinter, pf);
job.setJobName(getCurrentDocViewer().getDoc().getName());
boolean ok = job.printDialog();
if (ok) {
try {
job.print();
} catch (PrinterException ex) {
/* The job did not successfully complete */
}
}
}
use of java.awt.print.PrinterException in project gephi by gephi.
the class SimpleHTMLReport method printButtonActionPerformed.
// </editor-fold>//GEN-END:initComponents
private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_printButtonActionPerformed
PrinterJob pjob = PrinterJob.getPrinterJob();
PageFormat pf = pjob.defaultPage();
pjob.setPrintable(this, pf);
try {
if (pjob.printDialog()) {
pjob.print();
}
} catch (PrinterException e) {
e.printStackTrace();
}
}
use of java.awt.print.PrinterException in project binnavi by google.
the class CGraphPrinter method print.
/**
* Prints a graph. The user is given the opportunity to choose a number of options from a dialog
* before.
*
* @param parent Parent window of created dialogs.
* @param graph The graph to print.
*/
public static void print(final JFrame parent, final ZyGraph graph) {
final String[] area = { "Print the visible part of the graph only", "Print the whole graph" };
final OptionHandler printOptions = new OptionHandler("Print Options");
printOptions.addInt("Poster rows", 1);
printOptions.addInt("Poster columns", 1);
printOptions.addBool("Add poster coordinates", false);
printOptions.addEnum("Print Area", area, 1);
final Graph2DPrinter gprinter = new Graph2DPrinter(graph.getView());
// show custom print dialog and adopt values
if (!printOptions.showEditor()) {
return;
}
gprinter.setPosterRows(printOptions.getInt("Poster rows"));
gprinter.setPosterColumns(printOptions.getInt("Poster columns"));
gprinter.setPrintPosterCoords(printOptions.getBool("Add poster coordinates"));
if (printOptions.get("Print Area").equals("Print the whole graph")) {
gprinter.setClipType(Graph2DPrinter.CLIP_GRAPH);
} else {
gprinter.setClipType(Graph2DPrinter.CLIP_VIEW);
}
// show default print dialogs
final PrinterJob printJob = PrinterJob.getPrinterJob();
PageFormat pageFormat = printJob.defaultPage();
final PageFormat pageFormat2 = printJob.pageDialog(pageFormat);
if (pageFormat2 == pageFormat) {
return;
}
pageFormat = pageFormat2;
// setup printjob.
// Graph2DPrinter is of type Printable
printJob.setPrintable(gprinter, pageFormat);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (final PrinterException exception) {
final String innerMessage = "E00119: " + "Graph could not be printed";
final String innerDescription = CUtilityFunctions.createDescription(String.format("The graph '%s' could not be printed because there was a problem with the printer.", graph.getRawView().getName()), new String[] { "There was a problem with the printer." }, new String[] { "The print operation could not be completed." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, exception);
}
}
}
use of java.awt.print.PrinterException in project jdk8u_jdk by JetBrains.
the class RadialGradientPrintingTest method createUI.
public static void createUI() {
f = new JFrame("RadialGradient Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final RadialGradientPrintingTest gpt = new RadialGradientPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
use of java.awt.print.PrinterException in project jdk8u_jdk by JetBrains.
the class TexturePaintPrintingTest method printTexture.
private static void printTexture() {
f = new JFrame("Texture Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
Aggregations