List of usage examples for com.itextpdf.text PageSize A4
Rectangle A4
To view the source code for com.itextpdf.text PageSize A4.
Click Source Link
From source file:Interfaces.ReporteProveedor.java
private void botonPdfActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonPdfActionPerformed JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivos pdf", "pdf"); chooser.setFileFilter(filter);//www .ja v a2s . c o m chooser.setDialogTitle("Guardar archivo"); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { String file = chooser.getSelectedFile().toString().concat(".pdf"); try { Document doc = new Document(PageSize.A4.rotate()); PdfWriter.getInstance(doc, new FileOutputStream(new File(file))); doc.open(); PdfPTable pdfTable = new PdfPTable(tablaProv.getColumnCount()); for (int i = 0; i < tablaProv.getColumnCount(); i++) { pdfTable.addCell(tablaProv.getColumnName(i)); } //extracting data from the JTable and inserting it to PdfPTable for (int rows = 0; rows < tablaProv.getRowCount(); rows++) { for (int cols = 0; cols < tablaProv.getColumnCount(); cols++) { pdfTable.addCell(tablaProv.getModel().getValueAt(rows, cols).toString()); } } doc.add(pdfTable); doc.close(); JOptionPane.showMessageDialog(null, "Los datos fueron exportados a pdf en el directorio seleccionado", "Mensaje de Informacion", JOptionPane.INFORMATION_MESSAGE); } catch (DocumentException ex) { } catch (FileNotFoundException ex) { } } }
From source file:jati.GerandoArquivoCarimbado.java
public static Document montaraAquivo(String caminho) { try {//from ww w . j a v a 2s . c om reader = new PdfReader(caminho); // n recebe o numero total de paginas //Tamanho da primeira Pagina //Cria Segundo PDF } catch (IOException e) { } Document documento = new Document(PageSize.A4); return documento; }
From source file:javaresturentdesktopclient.BillingPage.java
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: try {//ww w.j a va 2s .c o m Document doc = new Document(PageSize.A4.rotate()); String Datee = Date; PdfWriter.getInstance(doc, new FileOutputStream("d:/BillingTable_" + transactionId + "_" + Datee + ".pdf")); PdfPTable pdfTable = new PdfPTable(jTableMealOrder.getColumnCount()); //adding table headers for (int i = 0; i < jTableMealOrder.getColumnCount(); i++) { pdfTable.addCell(jTableMealOrder.getColumnName(i)); } //extracting data from the JTable and inserting it to PdfPTable for (int rows = 0; rows < jTableMealOrder.getRowCount(); rows++) { for (int cols = 0; cols < jTableMealOrder.getColumnCount(); cols++) { pdfTable.addCell(jTableMealOrder.getModel().getValueAt(rows, cols).toString()); } } doc.open(); Paragraph preface = new Paragraph("Biliing Id : " + transactionId + " DATE : " + Date + " TIME :" + Time + "\n\n\n\n"); preface.setAlignment(Element.ALIGN_LEFT); doc.add(preface); pdfTable.setHorizontalAlignment(Element.ALIGN_CENTER); doc.add(pdfTable); Paragraph preface1 = new Paragraph("\n\n\n\n\tTotal:" + Total + "\n\n"); preface1.setAlignment(Element.ALIGN_BASELINE); doc.add(preface1); doc.add(new Paragraph()); doc.add(new Paragraph("\n\n\n\nTHANK YOU")); doc.close(); System.out.println("done"); JOptionPane.showMessageDialog(null, "Printed", "Information", JOptionPane.INFORMATION_MESSAGE); } catch (DocumentException ex) { Logger.getLogger(BillingPage.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(BillingPage.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:jeanderson.br.nota.Notas.java
public boolean gerarNotas(int desconto) { PdfPTable tabela = new PdfPTable(new float[] { 0.7f, 0.18f, 0.2f }); Document doc = new Document(PageSize.A4, 72, 72, 72, 72); try {/*from w w w .ja v a 2 s . c o m*/ OutputStream os = new FileOutputStream("/Users/" + System.getProperty("user.name") + "/Google Drive/Notas Fiscais/PDF/" + nomeCliente + ".pdf"); PdfWriter.getInstance(doc, os); // instancio o pdf que vou gravar doc.open(); // abro o pdf // seleciono a fonte, tamanho Font f = new Font(Font.FontFamily.COURIER, 20, Font.BOLD); //crio o paragrafo. Paragraph p1 = new Paragraph("Nota Eletrnica", f); Paragraph p2 = new Paragraph("Comprador(a): " + nomeCliente + "\nEndereo: " + endereco + "\nBairro: " + bairro + " " + "Cidade: " + cidade + "\nVendedor: Jonatha Monteiro"); PdfPCell celula = new PdfPCell(p1); celula.setColspan(3); celula.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(celula); PdfPCell celula2 = new PdfPCell(p2); celula2.setColspan(3); tabela.addCell(celula2); PdfPCell nProduto = new PdfPCell(new Paragraph("Produto")); PdfPCell nValor = new PdfPCell(new Paragraph("Valor(UN)")); nProduto.setHorizontalAlignment(Element.ALIGN_CENTER); nValor.setHorizontalAlignment(Element.ALIGN_CENTER); tabela.addCell(nProduto); tabela.addCell("Quantidade"); tabela.addCell(nValor); double valorTotal = 0; for (int i = 0; i < this.produtos.size(); i++) { tabela.addCell(produtos.get(i)); tabela.addCell(quantidades.get(i)); tabela.addCell(valor.get(i)); valorTotal += Integer.parseInt(quantidades.get(i)) * Double.parseDouble(valor.get(i)); } Paragraph p3 = null; if (desconto == 0) { p3 = new Paragraph("Data de Emisso: " + new SimpleDateFormat("dd/MM/yyyy").format(new Date())); } else { p3 = new Paragraph( "\n\nData de Emisso: " + new SimpleDateFormat("dd/MM/yyyy").format(new Date())); } PdfPCell celula3 = new PdfPCell(p3); celula3.setColspan(1); tabela.addCell(celula3); DecimalFormat df = new DecimalFormat("###,##0.00"); Paragraph p4 = new Paragraph("Valor Total: R$" + df.format(valorTotal)); PdfPCell celula4 = null; double valorDesc = 0; double valorComDesc = 0; switch (desconto) { case 0: celula4 = new PdfPCell(p4); celula4.setColspan(2); tabela.addCell(celula4); break; case 1: valorDesc = (valorTotal * 7) / 100; valorComDesc = valorTotal - valorDesc; celula4 = new PdfPCell(new Paragraph("Total: R$" + df.format(valorTotal) + "\n- 7% Desconto\nValor a pagar: R$" + df.format(valorComDesc))); celula4.setColspan(2); tabela.addCell(celula4); break; case 2: valorDesc = (valorTotal * 10) / 100; valorComDesc = valorTotal - valorDesc; celula4 = new PdfPCell(new Paragraph("Total: R$" + df.format(valorTotal) + "\n - 10% Desconto\nValor a pagar: R$" + df.format(valorComDesc))); celula4.setColspan(2); tabela.addCell(celula4); break; case 3: valorDesc = (valorTotal * 12) / 100; valorComDesc = valorTotal - valorDesc; celula4 = new PdfPCell(new Paragraph("Total: R$" + df.format(valorTotal) + "\n- 12% Desconto\nValor a pagar: R$" + df.format(valorComDesc))); celula4.setColspan(2); tabela.addCell(celula4); break; case 4: valorDesc = (valorTotal * 15) / 100; valorComDesc = valorTotal - valorDesc; celula4 = new PdfPCell(new Paragraph("Total: R$" + df.format(valorTotal) + "\n- 15% Desconto\nValor a pagar: R$" + df.format(valorComDesc))); celula4.setColspan(2); tabela.addCell(celula4); break; } //tabela.addCell(celula4); tabela.setWidthPercentage(100.0f); doc.add(tabela); // adiciono a tabela doc.close(); os.close(); return false; } catch (FileNotFoundException ex) { Relatar.bug(Notas.class.getName(), ex.getLocalizedMessage()); Logger.getLogger(Notas.class.getName()).log(Level.SEVERE, null, ex); return true; } catch (DocumentException ex) { Relatar.bug(Notas.class.getName(), ex.getLocalizedMessage()); Logger.getLogger(Notas.class.getName()).log(Level.SEVERE, null, ex); return true; } catch (IOException ex) { Relatar.bug(Notas.class.getName(), ex.getLocalizedMessage()); Logger.getLogger(Notas.class.getName()).log(Level.SEVERE, null, ex); return true; } }
From source file:lcform.L2Controller.java
@FXML private void doPrinting(ActionEvent event) { print_btn.setVisible(false);//from w w w.j a va2s . c o m back_btn.setVisible(false); Scene scene = print_btn.getScene(); WritableImage snapshot = scene.snapshot(null); BufferedImage image = SwingFXUtils.fromFXImage(snapshot, null); File f = new File("test2.png"); try { ImageIO.write(image, "png", f); } catch (IOException ex) { } Document document = new Document(PageSize.A4, 0, 0, 0, 0); try { PdfWriter.getInstance(document, new FileOutputStream("Image.pdf")); document.open(); // BufferedImage img = ImageIO.read(new File("test1.png")); //File f = new File("test1.png"); Image image1 = Image.getInstance("test2.png"); document.add(image1); document.close(); } catch (Exception e) { e.printStackTrace(); } try { InputStream is = new BufferedInputStream(new FileInputStream("Image.pdf")); DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF; PrintService service = PrintServiceLookup.lookupDefaultPrintService(); DocPrintJob printJob = service.createPrintJob(); printJob.addPrintJobListener(new L2Controller.JobCompleteMonitor()); Doc doc = new SimpleDoc(is, flavor, null); PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); //attributes.add(new Destination(new java.net.URI("file:/home/jayesh/NetBeansProjects/myFile.ps"))); printJob.print(doc, attributes); //while(jobRunning) //{ // Thread.sleep(1000); //} is.close(); } catch (Exception ex) { } finally { System.out.println("exiting"); } System.out.println("Done"); try { con1(); Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/pro", username, password); String query = "insert into log values(?,?)"; PreparedStatement ps = con.prepareStatement(query); ps.setString(1, getCurUser()); Date date = new Date(); SimpleDateFormat df = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss"); ps.setString(2, "Printed Leaving Certificate Page2 at " + df.format(date)); ps.executeUpdate(); } catch (Exception ex) { ex.printStackTrace(); } print_btn.setVisible(true); back_btn.setVisible(true); }
From source file:lcform.LeavingCertificateController.java
@FXML private void doPrinting(ActionEvent event) { print_btn.setVisible(false);/*from w w w . ja va 2 s .co m*/ next.setVisible(false); Scene scene = print_btn.getScene(); WritableImage snapshot = scene.snapshot(null); BufferedImage image = SwingFXUtils.fromFXImage(snapshot, null); File f = new File("test2.png"); try { ImageIO.write(image, "png", f); } catch (IOException ex) { } Document document = new Document(PageSize.A4, 0, 0, 0, 0); try { PdfWriter.getInstance(document, new FileOutputStream("Image.pdf")); document.open(); // BufferedImage img = ImageIO.read(new File("test1.png")); //File f = new File("test1.png"); Image image1 = Image.getInstance("test2.png"); document.add(image1); document.close(); } catch (Exception e) { e.printStackTrace(); } try { InputStream is = new BufferedInputStream(new FileInputStream("Image.pdf")); DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF; PrintService service = PrintServiceLookup.lookupDefaultPrintService(); DocPrintJob printJob = service.createPrintJob(); printJob.addPrintJobListener(new LeavingCertificateController.JobCompleteMonitor()); Doc doc = new SimpleDoc(is, flavor, null); PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet(); //attributes.add(new Destination(new java.net.URI("file:/home/jayesh/NetBeansProjects/myFile.ps"))); printJob.print(doc, attributes); //while(jobRunning) //{ // Thread.sleep(1000); //} is.close(); } catch (Exception ex) { } finally { System.out.println("exiting"); } System.out.println("Done"); try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/pro", "root", "toor"); String query = "insert into log values(?,?)"; PreparedStatement ps = con.prepareStatement(query); ps.setString(1, getCurUser()); Date date = new Date(); SimpleDateFormat df = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss"); ps.setString(2, "Printed Leaving Certificate Page1 at " + df.format(date)); ps.executeUpdate(); } catch (Exception ex) { ex.printStackTrace(); } print_btn.setVisible(true); next.setVisible(true); }
From source file:library.Report.java
public void createPdf(String filename) throws DocumentException, IOException { // step 1/* ww w . ja va2s. c om*/ Document document = new Document(); // step 2 PdfWriter.getInstance(document, new FileOutputStream(filename)); document.addAuthor("Admin"); document.addTitle("Library report"); document.setPageSize(PageSize.A4); document.setMargins(36, 72, 108, 180); document.setMarginMirroring(true); document.open(); Font normal = new Font(Font.FontFamily.HELVETICA, 36f, Font.NORMAL, BaseColor.DARK_GRAY); Font normal1 = new Font(Font.FontFamily.HELVETICA, 18f, Font.NORMAL); Font normal2 = new Font(Font.FontFamily.HELVETICA, 12f, Font.NORMAL); document.add(new Paragraph("KNOWLEDGICA LIBRARY REPORT", normal)); document.add(new Phrase("\n")); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime()); document.add(new Paragraph(timeStamp, normal1)); document.add(new Paragraph("Amount of books " + DF.getText() + "\nAmount of Amount of checked in books " + jTextField1.getText() + "\nAmount of checked out books " + jTextField3.getText() + "" + "\nNunber of users " + jTextField4.getText() + "\nNumber of admins " + jTextField5.getText() + "\nNumber of librarians " + jTextField6.getText() + "\nNumber of guest " + jTextField7.getText() + "\nMost logged user " + jTextField8.getText() + "\nAmount of males " + jTextField9.getText() + "\nAmount of female " + jTextField10.getText() + "", normal2)); document.close(); }
From source file:lk.score.androphsy.report.ReportPdf.java
License:Open Source License
public String generatePdf(ArrayList<String> featurelist) { File repdir = new File(AndrospyMain.gb_CasePath + "Analysis/Reports"); if (!repdir.exists()) { repdir.mkdir();/* w ww.j a v a 2s. c o m*/ } Document document = new Document(PageSize.A4, 36, 36, 54, 36); Date date = new Date(); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); gen_date = sf.format(date); String name = AndrospyMain.gb_CasePath + "Analysis/Reports/" + "Report_" + gen_date + ".pdf"; SimpleDateFormat sf2 = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); AndrospyLog.Logdata(sf2.format(new Date()), "Generate report: " + name); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(name)); TableHeader event = new TableHeader(); writer.setPageEvent(event); event.setHeader("lk.score.androphsy.main.Androspy Evidence Report - Confidential"); document.open(); addMetaData(document); addTitlePage(document); addDevicePage(document); Iterator<String> it = featurelist.iterator(); while (it.hasNext()) { String feature = it.next(); System.out.println("report : " + feature); addContent(document, feature); } document.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } return name; }
From source file:LogBeanConsultas.BeanConsultaRad.java
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException { Document pdf = (Document) document; pdf.open();/* ww w . j ava 2 s . c o m*/ pdf.setPageSize(PageSize.A4); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext() .getContext(); String logo = servletContext.getRealPath("") + File.separator + "resources" + File.separator + "demo" + File.separator + "images" + File.separator + ".png"; pdf.add(Image.getInstance(logo)); }
From source file:Login.ventas.fproyectos.java
/** * Creates new form cliente//from ww w . j a v a 2 s.co m * @param user */ public fproyectos(Login user) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); @SuppressWarnings("MismatchedReadAndWriteOfArray") String[] fecha = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }; initComponents(); Calendar rightNow = Calendar.getInstance(); int ccyy = rightNow.get(Calendar.YEAR); int month = rightNow.get(Calendar.MONTH); setSize(d.width, d.height - 95); this.usuario = user; add(f); f.setLocation(jPanel1.getX(), jPanel1.getY()); add(f3); f3.setLocation(jPanel1.getX(), jPanel1.getY()); add(f4); f4.setLocation(jPanel1.getX(), jPanel1.getY()); add(f5); f5.setLocation(jPanel1.getX(), jPanel1.getY()); add(f2); f2.setLocation(jPanel1.getX(), jPanel1.getY()); f2.getjButton1().addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { ServiceHb helper = new ServiceHb(); helper.iniciarTransaccion(); Fcomisiones fc = helper.getFcomisiones(idcliente, idinstalacion); if (helper.getFcomisiones(idcliente, idinstalacion) == null) { fc = new Fcomisiones(); Calendar d = Calendar.getInstance(); fc.setFecha(new java.sql.Date(d.getTime().getTime())); fc.setClientes( (Clientes) helper.obtenerObjeto(Clientes.class, Integer.parseInt(idcliente))); fc.setInstalacion((Instalacion) helper.obtenerObjeto(Instalacion.class, Integer.parseInt(idinstalacion))); fc.setRentabilidad(f2.getjLabel20().getText()); fc.setValor1(f2.getjLabel11().getText().substring(2, f2.getjLabel11().getText().length())); fc.setValor2(f2.getjLabel2().getText().substring(3, f2.getjLabel2().getText().length())); fc.setDiferido(f2.getjLabel4().getText()); fc.setDias(numeroinstala); helper.crearObjeto(fc); helper.confirmarTransaccion(); helper.cerrarSesion(); JOptionPane.showMessageDialog(null, "Comision prepara con fecha " + Funcion.DateFormatSql(d.getTime())); } else { Calendar d = Calendar.getInstance(); fc.setFecha(new java.sql.Date(d.getTime().getTime())); fc.setRentabilidad(f2.getjLabel20().getText()); fc.setValor1(f2.getjLabel11().getText().substring(2, f2.getjLabel11().getText().length())); fc.setValor2(f2.getjLabel2().getText().substring(3, f2.getjLabel2().getText().length())); fc.setDiferido(f2.getjLabel4().getText()); fc.setDias(numeroinstala); helper.actualizarObjeto(fc); helper.confirmarTransaccion(); helper.cerrarSesion(); JOptionPane.showMessageDialog(null, "Actualizado / Comision prepara con fecha " + Funcion.DateFormatSql(d.getTime())); } } catch (Exception io) { System.out.println(io); } } }); f2.getjButton2().addMouseListener(new java.awt.event.MouseAdapter() { @Override @SuppressWarnings("UseSpecificCatch") public void mouseClicked(MouseEvent e) { float ancho = 0; try { Document documento = new Document(PageSize.A4, 0, 0, 0, 0); ancho = documento.getPageSize().getWidth() - 100; FileOutputStream ficheroPdf; PdfWriter writer = null; PdfWriter writer2 = null; String direccion = ""; Calendar now2 = Calendar.getInstance(); try { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); //Mostrar la ventana para abrir archivo y recoger la respuesta //En el parmetro del showOpenDialog se indica la ventana // al que estar asociado. Con el valor this se asocia a la // ventana que la abre. int respuesta = chooser.showOpenDialog(null); String cadena = ""; if (respuesta == JFileChooser.APPROVE_OPTION) { direccion = chooser.getSelectedFile().getAbsolutePath(); } Calendar d = Calendar.getInstance(); ficheroPdf = new FileOutputStream(direccion + "/" + idcliente + idinstalacion + ".pdf"); writer = PdfWriter.getInstance(documento, ficheroPdf); } catch (IOException ex) { System.out.println(ex.toString()); } ServiceHb helper = null; try { List<Productos> lt = null; helper = new ServiceHb(); helper.iniciarTransaccion(); PdfPTable tabla; PdfPCell casilla; PdfPTable salto = null; PdfPCell celda; Font fontpersonalizado = FontFactory.getFont("ARIAL", 7, Font.BOLD); Font fontpersonalizado2 = FontFactory.getFont("ARIAL", 7, Font.NORMAL); documento.open(); PdfContentByte canvas = writer.getDirectContent(); fondos(documento, canvas); //Materiales double total = 0; double total2 = 0; double total3 = 0; double total4 = 0; double total5 = 0; tabla = new PdfPTable(6); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); celda = new PdfPCell(new Paragraph("ADQUISICION DE MATERIALES")); celda.setColspan(6); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); float pagina = documento.getPageSize().getHeight() - 140; final float max = pagina; pagina = pagina - tabla.getRow(0).calculateHeights(); if (ltart != null) { Object nuevo2[] = { "FECHA", "DETALLE", "CANT.", "PRECIO", "SUBTOTAL", "TOTAL DIARIO" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; double diario = 0; int turno = 0; for (int i = 0; i < ltart.size(); i++) { turno = 0; fact = helper.getFacturafecha(ltart.get(i).getIdfactura()); String fecha = ""; if (fact != null) { fecha = Funcion.DateFormatSql(fact.getFecha()); } if ((i + 1) == ltart.size()) { diario = diario + Double.parseDouble(ltart.get(i).getTotal()); turno = 1; } else { fact2 = helper.getFacturafecha(ltart.get(i + 1).getIdfactura()); String fecha2 = ""; if (fact2 != null) { fecha2 = Funcion.DateFormatSql(fact2.getFecha()); if (fecha.equalsIgnoreCase(fecha2)) { diario = diario + Double.parseDouble(ltart.get(i).getTotal()); } else { diario = diario + Double.parseDouble(ltart.get(i).getTotal()); turno = 1; } } } String uni = "$ " + df.format(Double.parseDouble(ltart.get(i).getUnitario())) .replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(ltart.get(i).getTotal())).replace(",", "."); total = total + Double.parseDouble(ltart.get(i).getTotal()); if (turno == 0) { Object nuevo[] = { fecha, ltart.get(i).getDescripcion(), ltart.get(i).getCantidad(), uni, tot, "" }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); if (((String) obj).equalsIgnoreCase("")) { celda.setBorder(Rectangle.RIGHT); } celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } } else { Object nuevo[] = { fecha, ltart.get(i).getDescripcion(), ltart.get(i).getCantidad(), uni, tot, "$ " + df.format(diario).replace(",", ".") }; int va = 0; for (Object obj : nuevo) { va++; celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); if (va == 5) { celda.setBorder(Rectangle.BOTTOM); } celda.setColspan(1); celda.setBorderColor(new Color(195, 195, 195)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } diario = 0; } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 11) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(6); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); pagina = max; tam = 0; } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell( new Paragraph("Adquisicin de Materiales", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(4); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); /*Parte 2*/ tabla = new PdfPTable(4); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1, 1 }); celda = new PdfPCell(new Paragraph("MANO DE OBRA TECNICOS")); celda.setColspan(4); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "CANT.", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; double diario = 0; int turno = 0; for (Ctepagar list1 : list) { if (list1.getDetalle().contains("ci:")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String[] cadena = desc.split(" "); String result = ""; int contador = 0; for (String n : cadena) { if (n.contains("ci:")) { result = result + ", "; contador++; } else { result = result + n + " "; } } result = result.substring(0, result.length() - 2); String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total2 = total2 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, result, "" + contador, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 90) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado2))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(4); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Mano de Obra Tcnicos", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(2); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total2).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph("TRANSPORTE")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; for (Ctepagar list1 : list) { if (list1.getDetalle().contains("Transporte")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String result = ""; String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total3 = total3 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, desc, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 50) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado2))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Transporte", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total3).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph("COMBUSTIBLE")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; for (Ctepagar list1 : list) { if (list1.getDetalle().contains("Combustible")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String result = ""; String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total4 = total4 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, desc, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 50) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Combustible", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total4).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); //Extras tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph("EXTRAS")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; for (Ctepagar list1 : list) { if (!list1.getDetalle().contains("Combustible") && !list1.getDetalle().contains("ci:") && !list1.getDetalle().contains("Transporte")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String result = ""; String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total5 = total5 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, desc, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 50) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Extra", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total5).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); //Final Vendedor tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph(nombrecliente)); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Venta")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_LEFT); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); Object nuevo2[] = { "FECHA", "DETALLE", "TOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo3[] = { "", nombreinstalacion, totalinstalacion }; for (Object obj : nuevo3) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("INVERSION", new Font(fontpersonalizado))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); Object nuevo4[] = { "Uso de Materiales", "", "$ " + df.format(total).replace(",", ".") }; for (Object obj : nuevo4) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo5[] = { "Mano de obra tcnicos", "", "$ " + df.format(total2).replace(",", ".") }; for (Object obj : nuevo5) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo6[] = { "Transporte", "", "$ " + df.format(total3).replace(",", ".") }; for (Object obj : nuevo6) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo7[] = { "Combustible", "", "$ " + df.format(total4).replace(",", ".") }; for (Object obj : nuevo7) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo71[] = { "Extras", "", "$ " + df.format(total5).replace(",", ".") }; for (Object obj : nuevo71) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo8[] = { "Total Inversin", "", "$ " + df.format(total + total2 + total3 + total4).replace(",", ".") }; for (Object obj : nuevo8) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_LEFT); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); Object nuevo9[] = { "Utilidad del proyecto", "", "$ " + df.format(proyectoval - total - total2 - total3 - total4).replace(",", ".") }; for (Object obj : nuevo9) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setColspan(1); celda.setBorder(PdfPCell.NO_BORDER); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo10[] = { "Rentabilidad ", "", df.format(porcent).replace(",", ".") + " %" }; for (Object obj : nuevo10) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); /*Fin Parte 3*/ documento.close(); helper.cerrarSesion(); } catch (Exception ex) { documento.close(); } JOptionPane.showMessageDialog(null, "PDF Generado"); } catch (Exception io) { System.out.println(io); } } }); f.getjTable1().addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = f.getjTable1().getSelectedRow(); int col = f.getjTable1().getSelectedColumn(); if (col == 4) { f2.setVisible(true); f.setVisible(false); idcliente = f.getjTable1().getValueAt(row, 5).toString(); idinstalacion = f.getjTable1().getValueAt(row, 6).toString(); f2.getjLabel15().setText(f.getjTable1().getValueAt(row, 0).toString()); f2.getjLabel8().setText(f.getjTable1().getValueAt(row, 2).toString()); nombrecliente = f.getjTable1().getValueAt(row, 0).toString(); nombreinstalacion = f.getjTable1().getValueAt(row, 2).toString(); updateTablas up = new updateTablas(1); up.start(); } } }); f5.getjComboBox1().addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { DefaultTableModel temp2 = (DefaultTableModel) f5.getjTable2().getModel(); for (int i = temp2.getRowCount() - 1; i >= 0; i--) { temp2.removeRow(i); } f5.setComi(null); f5.setNinstalacion(""); f5.setNcliente(""); f5.setList(null); f5.setId(""); updateTablas up = new updateTablas(4); up.start(); } }); f3.getjTable1().addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = f3.getjTable1().getSelectedRow(); int col = f3.getjTable1().getSelectedColumn(); if (col == 6) { visible(f4); fcomisiones = f3.getjTable1().getValueAt(row, 6).toString(); try { ServiceHb helper = new ServiceHb(); helper.iniciarTransaccion(); Fcomisiones ft = (Fcomisiones) helper.obtenerObjeto(Fcomisiones.class, Integer.parseInt(fcomisiones)); numeroinstala = ft.getDias(); f4.setIdcliente("" + ft.getClientes().getId()); f4.setIdinstalacion("" + ft.getInstalacion().getId()); f4.getDiasint().setText(numeroinstala); helper.cerrarSesion(); } catch (Exception io) { } f4.getjLabel1().setText(fcomisiones); f4.getC1().setText(f3.getjTable1().getValueAt(row, 0).toString()); f4.getC2().setText(f3.getjTable1().getValueAt(row, 1).toString()); double campo1 = Double .parseDouble(f3.getjTable1().getValueAt(row, 3).toString().replace("$ ", "")); double campo2 = Double .parseDouble(f3.getjTable1().getValueAt(row, 4).toString().replace("-$ ", "")); f4.getC3().setText(f3.getjTable1().getValueAt(row, 3).toString()); f4.getC4().setText(f3.getjTable1().getValueAt(row, 4).toString()); f4.getC5().setText(f3.getjTable1().getValueAt(row, 5).toString()); f4.getC6().setText("$ " + df.format((campo1 - campo2)).replace(",", ".")); updateTablas up = new updateTablas(3); up.start(); } } }); setVisible(false); }