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
将Icon
和String
添加到JLabel
,然后设置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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.