简体   繁体   中英

Problem In Adding an Icon to the Label of a JCheckBox Component

I try to describe an image through HTML tag as follow :

http://www.exampledepot.com/egs/javax.swing/checkbox_AddIcon.html

If I use the following HTML tag, it works

<html><table cellpadding=0><tr><td><img src=file:C:\user\network-transmit-receive.png/></td><td width=3><td>Hello World</td></tr></table></html>

However, when I use the following HTML tag, it doesn't work in Windows XP (I am not sure other Windows)

<html><table cellpadding=0><tr><td><img src=file:C:\user directory with space\network-transmit-receive.png/></td><td width=3><td>Hello World</td></tr></table></html>

Since there might be possibility user directory name contains space. However can I encode the directory name, so that it is recognized by JCheckBox?

You should quote your directory names such as

<img src="C:\\user directory with space\\network-transmit-receive.png"/>

, and also I don't believe "file://" protocol is required. You might want to check out the HTML and XHTML (more strict version of HTML which will replace it) tutorials from the W3Schools website. The W3C Validators are also useful tools in pinpointing what may be wrong in your page markup.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM