avevo sbagliato io.
ho dovuto fare questa modifica qua nel JPanel dove riempio la JTable:
codice:
private ArrayList<ArrayList<String>> map = null;
public PanelTable() {
initComponents();
try {
map = dbman.select();
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
} catch (ClassNotFoundException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
}
sbman.select() è il metodo che esegue la query.
prima era richiamato nell'evento di un JButton e per questo poi i valori nn passavano alla classe PDF.
solo che così mi si è rallentato un pò l'avvio del programma.
cmq a parte questo piccolo inconveniente tutto risolto:
codice:
public class ExportPdf {
public void createPdf(ArrayList<ArrayList<String>> map, String file) throws FileNotFoundException, DocumentException {
Document document = new Document(PageSize.A4, -65F, -65F, 100F, 80F);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
document.open();
PdfPTable pdftable = new PdfPTable(7);
PdfPCell cellID = new PdfPCell(new Paragraph("ID"));
cellID.setColspan(1);
PdfPCell cellTitle = new PdfPCell(new Paragraph("TITLE"));
cellTitle.setColspan(1);
PdfPCell cellAuthor = new PdfPCell(new Paragraph("AUTHOR"));
cellAuthor.setColspan(1);
PdfPCell cellEditor = new PdfPCell(new Paragraph("EDITOR"));
cellEditor.setColspan(1);
PdfPCell cellPrice = new PdfPCell(new Paragraph("PRICE"));
cellPrice.setColspan(1);
PdfPCell cellIsbn = new PdfPCell(new Paragraph("ISBN"));
cellIsbn.setColspan(1);
PdfPCell cellNote = new PdfPCell(new Paragraph("NOTE"));
cellNote.setColspan(1);
pdftable.addCell(cellID);
pdftable.addCell(cellTitle);
pdftable.addCell(cellAuthor);
pdftable.addCell(cellEditor);
pdftable.addCell(cellPrice);
pdftable.addCell(cellIsbn);
pdftable.addCell(cellNote);
for (int j = 0; j < map.size(); j++) {
Object[] temp = map.get(j).toArray();
for (int k = 0; k < temp.length; k++) {
PdfPCell cellMap = new PdfPCell(new Paragraph(temp[k].toString()));
cellMap.setColspan(1);
pdftable.addCell(cellMap);
}
}
document.add(pdftable);
document.close();
}
}
grazie!!