• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextPane + setIcon

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I am writting a Chat server/client program. There I have this code to display the incomming messages and the emotions(gif). But the problem I am having is, when I have the 'setIcon() method, the string message does not appear. I want to have both the emotions and the message to appear. So could you please help me to do this. Do I have to follow some other way to do what I want or what are changes I have to make.
Thank you very much.

pcJTP := JTextPane
try {
// Get the text pane's document
StyledDocument doc = (StyledDocument)pcJTP.getDocument();

// Create a style object and then set the style attributes
Style style = doc.addStyle("", null);

// Italic
StyleConstants.setItalic(style, cti);

// Bold
StyleConstants.setBold(style, ctb);

// Font family
StyleConstants.setFontFamily(style, ctf);

// Font size
StyleConstants.setFontSize(style, ctfs);

// Foreground color
StyleConstants.setForeground(style, ctfc);


/***************************************/
Problem

StyleConstants.setIcon(style, ctic);

/***************************************/


// Append to document
doc.insertString(doc.getLength(), ctm+"\n", style);

} catch (BadLocationException e) {
JOptionPane.showMessageDialog(this,"Error! ER-CCL-002");

}
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!