• Post Reply Bookmark Topic Watch Topic
  • New Topic

DefaultTableCellRenderer question  RSS feed

 
Henrik Engert
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a JTable with rows than need to change color if a certain value is set to true in a particular row. I have managed to do this, but the column that does not work is a checkbox column. If I use my own TableCellRenderer for this column, the output is not a checkbox but rather true/false. Do I need to write a seperate TableCellRenderer for a checkbox column to change it's background color?

Thanks.
 
Brian Cole
Author
Ranch Hand
Posts: 936
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Henrik Engert:
Do I need to write a seperate TableCellRenderer for a checkbox column to change it's background color?


Well there are other ways, but creating another renderer is probably the easiest. If you take a look at the source code for JTable.BooleanRenderer you'll see it's only 30 lines long. It wouldn't be hard to implement the same functionality but include your custom background color.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!