I know it's possible to use HTML but what if you are loading the icon image from a package instead of a directory?
How would you go about adding icon to a jcheckbox's label?
http://www.exampledepot.com/egs/javax.swing/checkbox_AddIcon.html
add Icon
and String
to the JLabel
, then set JLabel#setLabelFor(myJCheckBox)
I show various ways in my answer to "Loading images from jars for Swing HTML". But using an explicit URL (obtained from Class.getResource(String)
) should work just fine as the src
attribute of the img
element.