In my project I have to print JTable components in a pdf with all the customizations(like borders,colors etc). For this requirement I searched a little bit and found one cod
Hi I resolved the code by adding like below:-
cb.saveState();
PdfTemplate pdfTemplate = cb.createTemplate(table.getWidth(), table.getHeight());
Graphics2D g2 = pdfTemplate.createGraphics(table.getWidth(), table.getHeight());
/*g2.setColor(Color.BLACK);
g2.drawRect(x-2, y-2, table.getWidth()+2, table.getHeight()+2);*/
table.print(g2);
System.out.println("x="+x + "," + "y=" + y);
cb.addTemplate(pdfTemplate, x, y);
g2.dispose();
cb.restoreState();
A JTable
is notoriously difficult to get rendered correctly for images (or I guess, printing). See this thread on which some of the gurus weigh in with tips.
Looking closely at the screenshots of that thread suggests that the default Metal table has no border on the far left.
The table in Nimbus PLAF does, though.