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
adding border to jcheckbox
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.
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 layouts –
Teddytedeschi
Thank you. Geez, setBorderPainted? WTF Why? –
Depurative
© 2022 - 2024 — McMap. All rights reserved.