Aprovechando el componente JTextPane, y teniendo una lista de iconos disponible (esto es lo que a mi me falta) podemos incluir emoticonos en el chat.
Para ello implementamos algo así como:
int i,j = 0;
i = sLinea.indexOf(":P",j);
StyledDocument doc = (StyledDocument)texto.getDocument();
Style style = doc.addStyle("StyleName", null);
while (i > 0)
{
doc.insertString(doc.getLength(), sLinea.substring(j, i),null);
// The image must first be wrapped in a style
StyleConstants.setIcon(style, new ImageIcon("icono.jpg"));
// Insert the image at the end of the text
doc.insertString(doc.getLength(), "ignored text", style);
j = i + 2;
i = sLinea.indexOf(":P",j);
}
doc.insertString(doc.getLength(), sLinea.substring(j)+"\n",null);
Y para este caso, cuando añadimos en el mensaje :P nos añade el emoticono.
no puedes pasar el codigo completo ???
ResponderEliminar