Question

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

Was it helpful?

Solution

add Icon and String to the JLabel, then set JLabel#setLabelFor(myJCheckBox)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top