Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Removing cell borders from JTables

807606Mar 12 2007 — edited Mar 12 2007
Sorry(ish) for double posting, but I am getting desperate.

Does anyone know how to remove all the borders (cell borders and table border) from a JTable? I am trying to insert these tables into a JTextPane without the border, but they just aren't shifting.

I have tried setting the border to null, I have tried setting the border to a new EmptyBorder(0,0,0,0), I have tried setting the InterCellSpacing to a new Dimension(0,0), (or null), I have tried implementing a new class that implements TableCellRenderer and returns the border as an EmptyBorder (or null), and I have also tried setting the DefaultTableCellRenderer to null.

All the above (with the exception of the last one, which wipes the entire table) simply have no effect whatsoever. I have extensively searched APIs, Tutorials, related pages, and similar posts on this forum, but none of them have been much help (apart from suggesting one of the following).

I understand now that Java doesn't make this easy, but I don't believe it is impossible. All I want to do is have the text aligned in table format, just without the borders (but using tabs is not an option because the window will be resizable and the JTable compensates for that).

Any suggestions would be greatly appreciated, thank-you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 9 2007
Added on Mar 12 2007
5 comments
1,189 views