Search code examples
javaswingjtextpanejeditorpanechatroom

JTextPane or JEditorPane for a Chatroom


I have to make a chatroom like this one :

enter image description here

The message displayed also have to show the smileys and everything myst be copy/pastable like in Skype.

I don't know what to choose between the JEditor and JTextpane. I tried both I faced the following difficulties :

JEditorPane :

  • Copy/Pastable, can show the smileys and copy paste them.
  • I can't set the leftIndent of the message when I set the content to text/html

JTextPane :

  • I can set the leftIndent
  • Can't copy/paste the smiley Icons when I set the text content to html.
  • Can't display the smiley in the message

Maybe I'm wrong and I don;t know enough things so I would like to hear your opinions :)

Thank you very much.

Regards


Solution

  • Use JTextPane. Set content type to text/html. And place appropriate html via setText();

    That's about local images http://java-sl.com/tip_local_images.html

    And this one about smiles http://java-sl.com/tip_autoreplace_smiles.html