1 Attachment(s)
JCheckBox help is this possible?
i have a JCheckBox on my GUI and i want it to look like this
Attachment 747
is there a way i can make it blue under only the letters? i tried setbackground(Color.BLUE) but it makes the color go all the way around where the check mark and such is too but i only want it to go under the letters like that not the whole thing...so is this possible? i looked at the JCheckBox api but i didnt find anything that would let me put the color under the text or am i missing it?
Re: JCheckBox help is this possible?
The quick and dirty solution would be to just use a JLabel and a JCheckBox with no text and slap them into a JPanel. There's probably a better way though.
Re: JCheckBox help is this possible?
Re: JCheckBox help is this possible?
Actually the one thing that'll miss is clicking on the text to change the status of the check box. That's just a MouseListener though.
Re: JCheckBox help is this possible?
There is a way to do this by using java.awt.font.TextAttribute and java.util.Map. This way you won't need a MouseListener. The general form, I believe would be like this:
Code :
Map<TextAttribute, Color> attributes = new Hashtable<TextAttribute, Color>();
attributes.put(TextAttribute.BACKGROUND, Color.YELLOW);
component.setFont( new Font(attributes) );
You may need to play around with it a bit but that should help you out.
EDIT: So I changed the code a bit and it seems Ok now. I got the code, basically, from Oracle
Re: JCheckBox help is this possible?
thanks and that link has some other stuff i can use too :D