【问题标题】:JTextPane HTML Image integrationJTextPane HTML 图像集成
【发布时间】:2012-01-15 16:25:34
【问题描述】:

我有一个 JTextPane 并且我做到了:

HTMLEditorKit kit = new HTMLEditorKit();
HTMLDocument doc = new HTMLDocument();`

this.setEditorKit(kit);
this.setDocument(doc);

然后我做:

profilePictureSrc = "http://ola/profilePicture1.jpg";
chatContent ="<img src=\"" + profilePictureSrc + "\">";

其中 profilePictureSrc 是一个 URL 对象。

它有效,但我必须使用字符串而不是 URL (Java Hashtable put method slow down my application)

我该怎么做?我是否必须将图片文件放在某处并使用相对路径来访问它们?非常感谢您的想法

最好的问候

【问题讨论】:

    标签: java html swing image jtextpane


    【解决方案1】:

    您可以将 url 对象转换为字符串。

    字符串 urlstring = myurl.toString();

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多