• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Set the background Color to JTable of Chekckbox

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your first column is not a String is it
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks it help to my project
 
reply
    Bookmark Topic Watch Topic
  • New Topic