如何在JTextPane中添加图像? [英] How to add images in JTextPane?
本文介绍了如何在JTextPane中添加图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想让用户在 JTextPane
中复制并粘贴 图片
。请帮帮我。
I want to give the user the facility to copy and paste Images
in JTextPane
. Please help me.
推荐答案
你需要一个StyledDocument,就像HTML一样。因此将内容类型设置为text / html。然后< img src =file:...>
将链接到文件系统上的图像。
You need a StyledDocument, like resulting from HTML. Hence set the content type to "text/html". Then <img src="file:...">
will link to an image on the file system.
然后你可以从文件或图像中提供拖放或粘贴(后者你必须保存在你自己的文件中)。
Then you can provide drag-and-drop or paste from File or Image (the latter you have to save in your own files).
这篇关于如何在JTextPane中添加图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文