问题描述
我必须像这样建立一个聊天室:
I have to make a chatroom like this one :
显示的消息还必须显示笑脸,并且所有内容都必须像在Skype中一样被复制/粘贴.
The message displayed also have to show the smileys and everything myst be copy/pastable like in Skype.
我不知道在JEditor和JTextpane之间选择什么.我尝试了都遇到以下困难:
I don't know what to choose between the JEditor and JTextpane. I tried both I faced the following difficulties :
JEditorPane:
JEditorPane :
- 复制/粘贴,可以显示笑脸并将其粘贴粘贴.
- 将内容设置为text/html时,无法设置消息的leftIndent
JTextPane:
JTextPane :
- 我可以设置leftIndent
- 将文本内容设置为html时,无法复制/粘贴笑脸图标.
- 无法在邮件中显示笑脸
也许我错了,我不了解足够的事情,所以我想听听你的意见:)
Maybe I'm wrong and I don;t know enough things so I would like to hear your opinions :)
非常感谢您.
致谢
推荐答案
使用JTextPane.将内容类型设置为text/html.并通过setText();放置适当的html;
Use JTextPane. Set content type to text/html. And place appropriate html via setText();
那是关于本地图像的 http://java-sl.com/tip_local_images.html
That's about local imageshttp://java-sl.com/tip_local_images.html
这与微笑有关 http://java-sl.com/tip_autoreplace_smiles.html
这篇关于聊天室的JTextPane或JEditorPane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!