tags:

views:

51

answers:

1

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?

+1  A: 

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.

raptors
new File("C:\user\network-transmit-receive.png").toURI().toURL().toString() will return "file:C:\user\network-transmit-receive.png"
Yan Cheng CHEOK
OK, but if you are specifying it manually in the `<img>` tag, you can do without the `file://` protocol prefix. Wouldn't hurt including it, but point in hand is quotes are required around the file location string in the 'src' attribute.
raptors