• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can we keep a jCheckbox, in a jTable, cell selection color the same as the row selection color?

 
Peter Lock
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I have started using jTables with jCheckboxes, and have the situation wherein when I click on the checkbox in a JTable, and hold the mouse down, the selected colour of the checkbox cell becomes white. How can we keep the selection colour of the cell the same as the row selection colour. Any help would be greatly appreciated. Please find attached a cut down compilable piece of code. Im trying to make this piece of code work so that when a cell checkbox is clicked the row selection colour doesn't change.

Best Regards,


 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code is taken from the DefaultCellEditor class:



Based on the comment I would guess the problem is that the background color of the renderer has not been set at the time the editor is invoked.

So you would need to create a custom editor that sets the background for you. For example:



and you add the editor to the table using:




 
Peter Lock
Greenhorn
Posts: 24
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob

Thank-you very much for teaching me. This worked a treat. Perfect and easy to understand.

Best Regards and have a good day

Peter
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!