adding border to jcheckbox
Asked Answered
P

1

6

Does anyone know if there is an easy way to put a border around a JCheckBox object including the label? setBorder doesn't seem to have any effect. I know I could put each checkbox inside of a JPanel and border that, but is there no way to border the entire JCheckBox by itself? Thanks

Purism answered 2/12, 2010 at 12:47 Comment(0)
P
10

on a jcheckbox the setborder does work, its just that the border is not painted. all you have to do is call setBorderPainted(true) and it should work.

Purism answered 2/12, 2010 at 12:48 Comment(3)
From javadoc for setBorder() "Although technically you can set the border on any object that inherits from JComponent, the look and feel implementation of many standard Swing components doesn't work well with user-set borders. In general, when you want to set a border on a standard Swing component other than JPanel or JLabel, we recommend that you put the component in a JPanel and set the border on the JPanel."Grafting
@ka3ak, still useful when coding/testing/debugging component layoutsTeddytedeschi
Thank you. Geez, setBorderPainted? WTF Why?Depurative

© 2022 - 2024 — McMap. All rights reserved.