Pergunta

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

Foi útil?

Solução

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

Outras dicas

(Additional to the answer of StanislavL.) At least in Java 1.7 leftindent works for JTextPane:

<html>
  <head>
    <style type='text/css'>
        p { text-indent: 20px; }
    </style>
  </head>
  <body>
    <p style="margin-top: 0">
    The text.
    </p>
  </body>
</html>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top