JCheckBox problem Please help  
Author Message
Praveen homkar via JavaKB.com





PostPosted: 2005-2-22 17:32:00 Top

java-programmer, JCheckBox problem Please help Hi All

My question is how to remove the border from inner rectangle of a
JCheckBox.

A JCheckBox has 2 rectangles,it is possible to remove the boder from the
outside one ,but what about the rectangle where the user clicks.(I am
referring this rectangle as inner rectangle)

Hoping a quick reply

Praveen

--
Message posted via http://www.javakb.com
 
John McGrath





PostPosted: 2005-2-24 19:48:00 Top

java-programmer >> JCheckBox problem Please help On 2/22/2005 at 4:32:01 AM, Praveen homkar via JavaKB.com wrote:

> My question is how to remove the border from inner rectangle of a
> JCheckBox.
>
> A JCheckBox has 2 rectangles,it is possible to remove the boder from the
> outside one ,but what about the rectangle where the user clicks.(I am
> referring this rectangle as inner rectangle)

Are you referring to the checkbox icon? That is the little box that is on
the left (by default) and that contains the check mark. The Icon for a
JCheckBox (and for a JRadioButton, too) is a little more aware of its
context than most icons. It looks at the JCheckBox's model and paints
itself differently depending on whether the model is selected.

You can create your own "select-aware" Icon implementation and replace the
icon for the JCheckBox. For an example of how this is done, see one of
the standard checkbox icons, such as
javax.swing.plaf.metal.MetalCheckBoxIcon.

Be aware that this is look-and-feel dependent, so even if your icon looks
fine with one L&F, it may no look so good if the user changes the L&F.
Unless you are in control of the L&F, you may need to consider this.

--
Regards,

John McGrath
 
Praveen homkar via JavaKB.com





PostPosted: 2005-2-25 12:45:00 Top

java-programmer >> JCheckBox problem Please help Hi John McGrath

Thank you very much for the help.

idea of changing the icon works.

praveen

--
Message posted via http://www.javakb.com