我有一个 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 )
我该怎么做?我是否必须将图片文件放在某个地方并使用相对路径来访问它们?非常感谢你的想法
最好的问候
最佳答案
您可以将 url 对象转换为字符串。
字符串 urlstring = myurl.toString();
关于java - JTextPane HTML 图像集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8427515/