• Post Reply Bookmark Topic Watch Topic
  • New Topic

JCheckBox problem

 
Duane Riech
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • 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....
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!