We have a requirement to draw a JTable on a pdf. For this requirement I had taken JTable and directly print onto the pdf. But I didn't get the Left and Top borders for a JTable. Plus I have a requirement to cutomize a cell border for a table. Is there anyway I can give different color borders to a cell in a JTable? For eg:-
Left Border = Grid Color
Top Border = Grid Color
Right Border = Black Color
Bottom Border = Grid Color
Any suggestions related to this would be very helpful?
The link @andrewthompson provided should give you an answer to the first part of your question of getting the Table's borders to print (a.k.a. Why does the JTable header not appear in the image?)
To get different color inner borders in the Table (I believe that was your second question), you'll have to use a combination of the
MatteBorder
andCompoundBorder
in conjunction with aTableCellRenderer
.Thanks for all your code. I really appreciate people who really help us by contributing their time and effort. Well all these solutions will solve the problem. I got a very good resolution on this with the below code:-
Thanks!
Add a MatteBorder to the table before you print.