Skip to Main Content

Java SE (Java Platform, Standard Edition)

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!

JTable: How to set row background color when using intercell spacing?

843806Apr 8 2009 — edited Apr 8 2009
My application needs to set some rows to have black text on a colored background (reverse video). So I created a custom cell renderer that handles that for me. Works great. I can set the fg/bg colors on the JLabel based on the table data.

I wanted a little more space around the data though, so I added some margin/padding using table.setIntercellSpacing(). I get the spacing I wanted, but the padding is using the table background color (black), not the cell component background color. So my row looks like a set of distinct colored rectangles, rather one long rectangle.

What am I missing to get the row background color set? Or should I use a different method to add space around the cell text?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2009
Added on Apr 8 2009
4 comments
682 views