如下图所示:
我用的是HtmlEditorKit而我用getText返回的Html是这样的text == <html>
  <head>  </head>
  <body>
    <p style="margin-top: 0">
      <img src="I:/my doc/work/email/test.gif">
      
    </p>
  </body>
</html>
插入图片的代码如下: selectedFile = chooser.getSelectedFile().getCanonicalFile();

//添加图片到jTextPane修改Doc
String img = selectedFile.getCanonicalPath(); 
if(img == null || (img != null && img.trim().length() == 0))
return ;

HTMLEditorKit  kit  =  (HTMLEditorKit) getJTextPane().getEditorKit();
                  jTextPane.setEditorKit(kit);
                  img = img.replaceAll("\\\\", "/");                   
                 
                 logger.info("img path ==" + img); 
kit.insertHTML((HTMLDocument)  jTextPane.getDocument(),  jTextPane.getCaretPosition(),   "<img  src=\"" + img+ "\""+">",0,0,HTML.Tag.IMG);为什么会只出现图片的图标呢?而且好像是不能载入的那种图标

解决方案 »

  1.   

    补充,我的这个软件是个邮件收发软件。
    发送邮件后生成的eml文件在outlook也能打开。
    用outlook打开的话这个文件正常的不得了。
      

  2.   

    我得给你一下,你在这个html编辑器里面的要显示的图片(即你图中没有显示出来的那个)是保存到哪里的?
    是本地还是web网络上?
      

  3.   

    <html> 
      <head>   </head> 
      <body> 
        <p style="margin-top: 0"> 
          <img src="I:/my doc/work/email/test.gif"> 
          
        </p> 
      </body> 
    </html> 这个html是没啥问题
    其他的就不太懂了 呵呵 
      

  4.   

    终于解决了,是因为少了个file:/// 
    标准的格式应该是 file:///i:/my docxxxxxxooooo在oe和ie和firefox下面少了file:///也能解析出来,但是JTextPane不行。
    呵呵