Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to change the 'check' in a JCheckbox

 
Brett Kurth
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - I'm wondering if anyone has tried this before. What I'm trying to code is to have a checkbox in my JTable row but instead of putting a 'check' in the checkbox, I want to change the color of the checkbox when it's checked and leave the background of the checkbox text normal. I've tried in my TableCellRenderer class to change the background of the checkbox, but it changes the color of the entire cell not just the checkbox. I'm hoping this is something easy but as I've never coded in Swing before, I'm at a loss as to how to do it.

I attached a pic of what I'm trying to do

maybe try using a button instead?

many thanks in advance for any help I can get.


checkbox example.png
[Thumbnail for checkbox example.png]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
initial thoughts are that a checkBox without a tick/check (not that hard to do) would look strange,
and that a JRadioButton would seem more suited to displaying different colors for selected/unselected.

either way you'd need to set your own Icon
 
Brett Kurth
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cool - I knew it was something easy. I know this looks horrible to me too but requirements are requirements.

thanks for pointing me in the right direction.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted this recently, it may be useful to you: https://forums.oracle.com/forums/thread.jspa?threadID=2346041
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic