• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I bold the text in a text area?  RSS feed

 
Alan Smith
Ranch Hand
Posts: 185
Firefox Browser Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am building a chat server/client and would like to have it so when a user sends a message, the message pops up in the main chat area beside their name, which I would like to be in bold font. Something like "Alan: Hello, how are you?". I can't find a way to do this with a text area or on a string. Do any swing components suitable for use as text areas support bolding of certain sections of the string that you will set to it?

Thanks
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into StyledEditorKit and its related classes.
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use a JTextPane to do this. Read the section from the Swing tutorial on An Example of Using Text Panes.
 
Alan Smith
Ranch Hand
Posts: 185
Firefox Browser Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:You should use a JTextPane to do this. Read the section from the Swing tutorial on An Example of Using Text Panes.

Cool, thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!