Example usage for java.awt.print PrinterException getMessage

List of usage examples for java.awt.print PrinterException getMessage

Introduction

In this page you can find the example usage for java.awt.print PrinterException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:canreg.client.gui.analysis.FrequenciesByYearInternalFrame.java

/**
 *
 *//*from  w w w.  j a va 2s  .  c  om*/
@Action
public void printTableAction() {
    try {
        if (!resultTable.print(JTable.PrintMode.NORMAL,
                new MessageFormat(java.util.ResourceBundle
                        .getBundle("canreg/client/gui/analysis/resources/FrequenciesByYearInternalFrame")
                        .getString("CANREG_FREQUENCIES_BY_YEAR") + " - " + rangeFilterPanel.getFilter()),
                null)) {
            System.err.println(java.util.ResourceBundle
                    .getBundle("canreg/client/gui/analysis/resources/FrequenciesByYearInternalFrame")
                    .getString("USER CANCELLED PRINTING"));
        }
    } catch (java.awt.print.PrinterException e) {
        System.err.format(java.util.ResourceBundle
                .getBundle("canreg/client/gui/analysis/resources/FrequenciesByYearInternalFrame")
                .getString("CANNOT PRINT %S%N"), e.getMessage());
    }
}

From source file:com.sshtools.sshterm.SshTermSessionPanel.java

/**
 *
 *//*from   w w  w.ja v a  2  s .c  o m*/
public void printScreen() {
    try {
        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:Store.SelectedPatient.java

private void btn_printActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_printActionPerformed
    MessageFormat header = new MessageFormat("Medical Report");
    MessageFormat footer = new MessageFormat("page{0,number,integer}");
    try {/*  www  . j ava  2 s  .  c  o  m*/
        select_PTable.print(JTable.PrintMode.NORMAL, header, footer);
    } catch (java.awt.print.PrinterException pe) {
        System.err.format("Cannot Print", pe.getMessage());
    }
}

From source file:com.openbravo.pos.sales.restaurant.JRetailTicketsBagRestaurantMap.java

private synchronized void printRetailCancelKotTicket(String sresourcename, RetailTicketInfo ticket,
        java.util.List<RetailTicketLineInfo> kot, Object ticketExt,
        java.util.List<ProductionPrinterInfo> printerInfo, int kotTicket) {
    java.util.List<TicketLineConstructor> allLines = null;
    logger.info("start printing the kot" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
    com.openbravo.pos.printer.printer.KotImagePrinter printer = new KotImagePrinter();
    com.openbravo.pos.printer.printer.KotBillPrinter printerKot = new KotBillPrinter();

    String storeLocation = m_App.getProperties().getProperty("machine.storelocation");
    kotTicketLinelist = kot;/*  w  ww .ja  va2 s  .  c o m*/
    for (int j = 0; j < printerInfo.size(); j++) {
        java.util.List<RetailTicketLineInfo> uniqueProductionAreas = new ArrayList<RetailTicketLineInfo>();
        for (int i = 0; i < kotTicketLinelist.size(); i++) {
            if (printerInfo.get(j).getProductionAreaType()
                    .equals(kotTicketLinelist.get(i).getProductionAreaType())) {
                uniqueProductionAreas.add(kotTicketLinelist.get(i));
                kotTicketLinelist.get(i).setProductionArea(printerInfo.get(j).getProductionArea());
            }
        }
        logger.info("kot print count based on production areas" + uniqueProductionAreas.size());
        if (uniqueProductionAreas.size() != 0) {
            allLines = getRetailAllLines(ticket, ticketExt, uniqueProductionAreas, kotTicket);
            try {//Based on storelocation
                if (storeLocation.equals("BlrIndranagar") || storeLocation.equals("BlrKoramangala")
                        || storeLocation.equals("Chennai") || storeLocation.equals("Hyderabad")) {

                    printer.printKot(allLines, printerInfo.get(j).getPath());
                } else {
                    printerKot.print(allLines, printerInfo.get(j).getPath());
                }
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    kotlogger.info("Cancel Bill KOT Printed Successfully " + "," + "Username: "
                            + ticket.printUser() + "," + "Total kot count: " + uniqueProductionAreas.size()
                            + "," + "Printer Name: " + printerInfo.get(j).getPath() + "," + "Kot No: "
                            + kotTicket + "," + "Table: " + ticket.getTableName().toString() + ","
                            + "Order No: " + ticket.getOrderId() + "," + "Product Name: "
                            + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(1);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(4);
                    }

                }
            } catch (PrinterException ex) {
                logger.info("Order NO." + ticket.getOrderId() + " The printer action" + ex.getMessage());

                Logger.getLogger(JRetailPanelTicket.class.getName()).log(Level.SEVERE, null, ex);
                for (int i = 0; i < uniqueProductionAreas.size(); i++) {
                    logger.info("Cancel Bill KOT Print Failed  " + "," + "Username: " + ticket.printUser() + ","
                            + "Total kot count: " + uniqueProductionAreas.size() + "," + "Printer Name: "
                            + printerInfo.get(j).getPath() + "," + "Kot No: " + kotTicket + "," + "Table: "
                            + ticket.getTableName().toString() + "," + "Order No: " + ticket.getOrderId() + ","
                            + "Product Name: " + uniqueProductionAreas.get(i).getProductName() + "," + "Qty: "
                            + uniqueProductionAreas.get(i).getMultiply() + "," + "Timestamp: "
                            + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S").format(new Date()));
                    uniqueProductionAreas.get(i).setIsKot(0);
                    if (uniqueProductionAreas.get(i).getPreparationStatus() != 3) {
                        uniqueProductionAreas.get(i).setPreparationStatus(0);
                    }
                }

                showMessage(this, "KOT action not happened! Please retry");
            }
        }
    }
}

From source file:com.sshtools.sshterm.SshTerminalPanel.java

public void printScreen() {
    try {/*from   w ww  . ja va  2 s  . 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:rulebender.editors.dat.view.CustomizedChartComposite.java

/**
 * Creates a print job for the chart./*from w  ww.  j a v a  2 s .  com*/
 */
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./* www . j  a va  2s . c  om*/
 */
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:org.mwc.cmap.grideditor.chart.FixedChartComposite.java

/**
 * Creates a print job for the chart.//  w ww.  j a  va  2 s. c om
 */
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:org.ejbca.core.ejb.ra.EndEntityManagementSessionBean.java

private void print(EndEntityProfile profile, EndEntityInformation userdata) {
    try {/*from  ww  w  .  ja v  a 2 s  .co m*/
        if (log.isDebugEnabled()) {
            log.debug("profile.getUsePrinting(): " + profile.getUsePrinting());
        }
        if (profile.getUsePrinting()) {
            String[] pINs = new String[1];
            pINs[0] = userdata.getPassword();
            PrinterManager.print(profile.getPrinterName(), profile.getPrinterSVGFileName(),
                    profile.getPrinterSVGData(), profile.getPrintedCopies(), 0, userdata, pINs, new String[0],
                    "", "", "");
        }
    } catch (PrinterException e) {
        String msg = intres.getLocalizedMessage("ra.errorprint", userdata.getUsername(), e.getMessage());
        log.error(msg, e);
    }
}

From source file:org.ejbca.core.ejb.ra.UserAdminSessionBean.java

private void print(Admin admin, EndEntityProfile profile, UserDataVO userdata) {
    try {//from ww w  .  java 2 s  .  c om
        if (profile.getUsePrinting()) {
            String[] pINs = new String[1];
            pINs[0] = userdata.getPassword();
            PrinterManager.print(profile.getPrinterName(), profile.getPrinterSVGFileName(),
                    profile.getPrinterSVGData(), profile.getPrintedCopies(), 0, userdata, pINs, new String[0],
                    "", "", "");
        }
    } catch (PrinterException e) {
        String msg = intres.getLocalizedMessage("ra.errorprint", userdata.getUsername(), e.getMessage());
        log.error(msg, e);
        try {
            logSession.log(admin, userdata.getCAId(), LogConstants.MODULE_RA, new Date(),
                    userdata.getUsername(), null, LogConstants.EVENT_ERROR_NOTIFICATION, msg);
        } catch (Exception f) {
            throw new EJBException(f);
        }
    }
}