• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

JCheckBox problem

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using a JTable which includes a boolean value and a String.
I've written classes to extend JCheckBox implements TableCellRenderer and
IngrTableCellRender extends DefaultTableCellRenderer for the String.
Under certain conditions, I want to display a row in red, so I've implemented a setBackground(Color.red) and setForeground(Color.red) respectively, in each class. Everything works ok.
I'd ALSO like to disable the JCheckbox whenever I paint the row red. I included a line setEnabled(false); in the JCheckBox class, but I can still click the checkbox.
The getTableCellRendererComponent() routine IS being called and I'm executing the setEnabled() code.
In short, everything works, except I can't disable the JCheckBox.
Any ideas?
Thanks....
 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CellRenderer is to display data - that's it. Changing data in a cell is associated with CellEditor. If you want to make a cell uneditable, you should implement, isCellEditable() method on the TableModel of the Table - depending on your requirement.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic