adg
asked on
Change Color Inside JTextBox
cb = new JCheckBox("Hello");
chinButton.setBackground(C olor.pink) ;
The above changes the color surrounding the checkbox and its label but the background of the little box stays white. I would like to make the background of the little box a different color (not the same as the background. Can I do that?
chinButton.setBackground(C
The above changes the color surrounding the checkbox and its label but the background of the little box stays white. I would like to make the background of the little box a different color (not the same as the background. Can I do that?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> I tried it and it seems to do the same thing as setBackground.
it does :)
it does :)
using setOpaque() can sometimes help.
ASKER
OK, I tried setOpaque and it didn't seem to make a difference. I'm getting ready to try a different look and feel - maybe that will help? Is it really this hard to set the color of the inside of a checkbox?
which one are u using? try metal.
ASKER
I added this code but it didn;t help
try {
UIManager.setLookAndFeel(U IManager.g etCrossPla tformLookA ndFeelClas sName());
}
catch(Exception e) {}
I wonder why
UIManager.put("CheckBox.in teriorBack ground", Color.pink);
doesn't work. It comes up on google a lot
try {
UIManager.setLookAndFeel(U
}
catch(Exception e) {}
I wonder why
UIManager.put("CheckBox.in
doesn't work. It comes up on google a lot
ASKER
I just tried all the plaf's I could find - no luck :*<
ASKER
I just realized that some of my looks and feels were not getting set properly. I was swallowing the exception so I'm trying again. After more research I think that the "CheckBox.interiorBackgrou nd" might be specific to the windows look and feel.
ASKER
I found several examples on google that implemented a custom CheckBoxIcon class. I finally tried that and it worked. Thanks all for the help. I appreciate it!
:-)
ASKER