private void applyFilter() { tm.setRowCount(0); for (Object[] o : filterBackUp) { if (rowMatches(o)) tm.addRow(o); } }
private void openPrintableView() { /* JFrame d = new JFrame(); d.setSize(540, 480); d.setTitle("Version Imprimible"); d.setLayout(new BorderLayout());*/ try { // Creating document Document doc = new Document(PageSize.A4.rotate(), 20, 20, 20, 20); File temp = File.createTempFile(new GregorianCalendar().getTimeInMillis() + "", ".pdf"); temp.deleteOnExit(); PdfWriter.getInstance(doc, new FileOutputStream(temp)); doc.open(); Font nf = new Font(Font.FontFamily.UNDEFINED, 11, Font.NORMAL); Font bf = new Font(Font.FontFamily.UNDEFINED, 12, Font.BOLD); Phrase p1 = new Phrase(getPrintableTitle(), new Font(Font.FontFamily.UNDEFINED, 24, Font.BOLD)); Phrase p2 = new Phrase("Nombre: ", bf); Phrase p2_0 = new Phrase(App.user.getName(), nf); Paragraph parag = new Paragraph(); parag.add(p2); parag.add(p2_0); Phrase p3 = new Phrase("E-mail: ", bf); Phrase p3_0 = new Phrase(App.user.getMail(), nf); Paragraph parag_0 = new Paragraph(); parag_0.add(p3); parag_0.add(p3_0); PdfPTable pTable = new PdfPTable(tm.getColumnCount()); pTable.setWidthPercentage(100f); if (getWidthsPrintableView() != null) pTable.setWidths(getWidthsPrintableView()); for (int i = 0; i < tm.getColumnCount(); i++) { Phrase p = new Phrase(tm.getColumnName(i), bf); PdfPCell cell = new PdfPCell(p); cell.setGrayFill(.8f); pTable.addCell(cell); } for (int i = 0; i < tm.getRowCount(); i++) for (int j = 0; j < tm.getColumnCount(); j++) { Phrase p = new Phrase(tm.getValueAt(i, j) + "", nf); PdfPCell cell = new PdfPCell(p); cell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); pTable.addCell(cell); } doc.add(new Paragraph(p1)); doc.add(new Paragraph("\n")); doc.add(parag); doc.add(parag_0); doc.add(new Paragraph("\n")); doc.add(pTable); doc.close(); // open system editor Desktop.getDesktop().open(temp); /* //Reading document Viewer v = new Viewer(); v.setDocumentInputStream(new FileInputStream(temp)); v.activate(); d.add(v);*/ } catch (Exception e) { e.printStackTrace(); } /* d.setLocationRelativeTo(null); d.setVisible(true);*/ }