Exemplo n.º 1
0
 /** 打印 */
 private void print() {
   try {
     table.print();
   } catch (PrinterException e) {
     logger.warn("打印机未准备好. - " + e.getMessage() + TMFrame.class.getName());
   }
 }
  public void Print() {
    // If they didn't provide a mech exit
    if (Mechs.size() == 0) {
      return;
    }

    job.setJobName(jobName.trim());

    // Here is where we will show the print dialog, determine if it's a single mech or multiples
    if (useDialog) {
      if (Mechs.size() == 1) {
        if (!PrintDialog((PrintMech) Mechs.get(0))) return;
      } else {
        if (!BatchDialog()) return;
      }
    }

    // start building the print objects necessary
    GeneratePrints();

    job.setPageable(pages);
    boolean DoPrint = job.printDialog();
    if (DoPrint) {
      try {
        job.print();
      } catch (PrinterException e) {
        System.err.println(e.getMessage());
        System.out.println(e.getStackTrace());
      }

      Mechs.clear();
    }
  }
 private void imprimirButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_imprimirButtonActionPerformed
   try {
     stocksMensualesProductosTerminadosTable.print(JTable.PrintMode.FIT_WIDTH);
   } catch (java.awt.print.PrinterException e) {
     JOptionPane.showMessageDialog(
         this, e.getMessage(), "Error al imprimir", JOptionPane.ERROR_MESSAGE);
   }
 } // GEN-LAST:event_imprimirButtonActionPerformed
Exemplo n.º 4
0
  private void cmd_printActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cmd_printActionPerformed

    MessageFormat header = new MessageFormat("Report Print");
    MessageFormat footer = new MessageFormat("page{0,number,integer}");
    try {
      table1.print(JTable.PrintMode.NORMAL, header, footer);
    } catch (java.awt.print.PrinterException e1) {
      System.err.format("cannot print %s%n", e1.getMessage());
    }
  } // GEN-LAST:event_cmd_printActionPerformed
  public void PrintBattleforce() {
    if (battleforces.size() == 0) {
      return;
    }
    pages = new Book();
    page.setPaper(paper);

    if (jobName.isEmpty()) {
      jobName = "BattleForce";
    }
    if (battleforces.size() == 1) {
      BattleForce bf = ((BattleforcePrinter) battleforces.get(0)).getBattleforce();
      if (!bf.ForceName.isEmpty()) {
        jobName = bf.ForceName.trim();
      }
    }

    job.setJobName(jobName);

    if (useDialog) {
      for (int i = 0; i < battleforces.size(); i++) {
        BattleforcePrinter bf = (BattleforcePrinter) battleforces.get(i);
        dlgPrintBattleforce pForce =
            new dlgPrintBattleforce((javax.swing.JFrame) Parent, true, bf.getBattleforce());
        pForce.setLocationRelativeTo((javax.swing.JFrame) Parent);
        pForce.setVisible(true);
        if (!pForce.Result) {
          return;
        }

        bf.setType(pForce.Sheet);
      }
    }

    for (int i = 0; i < battleforces.size(); i++) {
      pages.append((BattleforcePrinter) battleforces.get(i), page);
    }

    job.setPageable(pages);
    boolean DoPrint = job.printDialog();
    if (DoPrint) {
      try {
        job.print();
      } catch (PrinterException e) {
        System.err.println(e.getMessage());
        System.out.println(e.getStackTrace());
      }
    }
  }
Exemplo n.º 6
0
    @Override
    public void stopRenderer() throws IOException {
      super.stopRenderer();

      try {
        printerJob.print();
      } catch (PrinterException e) {
        e.printStackTrace();
        throw new IOException(
            Messages.getInstance()
                .getString(
                    "PrintComponent.ERROR_0003_UNABLE_TO_PRINT",
                    e.getClass().getName(),
                    e.getMessage())); // $NON-NLS-1$
      }
    }
Exemplo n.º 7
0
  private void btImprimirActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btImprimirActionPerformed
    // TODO add your handling code here:

    btNovo.setEnabled(false);
    btEditar.setEnabled(true);
    btImprimir.setEnabled(true);
    btExcluir.setEnabled(false);
    btSalvar.setEnabled(true);
    btSair.setEnabled(true);
    tbPart.setEnabled(false);

    try {
      tbPart.print();
    } catch (PrinterException ex) {
      JOptionPane.showMessageDialog(this, "Não foi possível imprimir\n" + ex.getMessage());
    }
  } // GEN-LAST:event_btImprimirActionPerformed
Exemplo n.º 8
0
    @Override
    public void actionPerformed(ActionEvent arg0) {

      // Background this, as it takes a while.
      JabRefExecutorService.INSTANCE.execute(
          () -> {
            try {
              PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
              pras.add(new JobName(entry.map(BibEntry::getCiteKey).orElse("NO ENTRY"), null));
              previewPane.print(null, null, true, null, pras, false);

            } catch (PrinterException e) {
              // Inform the user... we don't know what to do.
              JOptionPane.showMessageDialog(
                  PreviewPanel.this,
                  Localization.lang("Could not print preview") + ".\n" + e.getMessage(),
                  Localization.lang("Print entry preview"),
                  JOptionPane.ERROR_MESSAGE);
              LOGGER.info("Could not print preview", e);
            }
          });
    }
Exemplo n.º 9
0
 @Override
 public void actionPerformed(ActionEvent e) {
   switch (e.getActionCommand()) {
     case "CHANGE":
       pf = PrinterJob.getPrinterJob().pageDialog(pf);
       setMediaSizeInfo();
       pages.setPageFormat(pf);
       break;
     case "PRINT":
       PrinterJob pjob = PrinterJob.getPrinterJob();
       pjob.setPageable(new MyPageable(pages.getNumberOfPages(), pf, p));
       if (pjob.printDialog() == false) return;
       try {
         pjob.print();
       } catch (PrinterException e1) {
         JOptionPane.showMessageDialog(
             this, "Druckfehler: " + e1.getMessage(), "Fehler", JOptionPane.WARNING_MESSAGE);
       }
       break;
     case "CANCEL":
       setVisible(false);
       break;
   }
 }