简体   繁体   English

向JCheckBox组件的标签添加图标时出现问题

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

I try to describe an image through HTML tag as follow : 我尝试通过HTML标签描述图像,如下所示:

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

If I use the following HTML tag, it works 如果我使用以下HTML标记,则可以使用

<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标记时,它在Windows XP中不起作用(我不确定其他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? 但是,我可以对目录名称进行编码,以便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. ,而且我也不认为需要“ file://”协议。 You might want to check out the HTML and XHTML (more strict version of HTML which will replace it) tutorials from the W3Schools website. 您可能想从W3Schools网站上查看HTMLXHTML (将替换为HTML的更严格版本)教程。 The W3C Validators are also useful tools in pinpointing what may be wrong in your page markup. W3C验证程序也是有用的工具,可用于查明页面标记中可能存在的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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