Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Set the background Color to JTable of Chekckbox  RSS feed

 
vinod Raj kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i have a created the JTable of 3 column, 1st Column is used as Check-box, 2nd and 3rd column used as String

i have created the checkbox as follows



and i have called the DefaultTableRender as follows




and for background color i used the DefaultTableCellRender as follows



Problem is in 1st Column, Background color will not appear it and other 2nd and 3rd column will get the background color
i need to get the background color to 1st Column
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your first column is not a String is it
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vinodrnsit kumar wrote:table.setDefaultRenderer(String.class, new DifferentColorRow());

Problem is in 1st Column, Background color will not appear

That's because the first column class is Boolean.class, not String.class.

An easy way to do this is to override prepareRenderer(...) and set the color there.
 
vinod Raj kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks it help to my project
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!