Results 1 to 3 of 3
  1. #1
    Psyclone is offline Member
    Join Date
    Jan 2010
    Posts
    81
    Rep Power
    0

    Default Varying colors within JTextArea

    Reading through the Java tutorials, it states that "[i]a given text area can display text in only one font and color.[i]" Is there any way to get around this?

    I have a JTextArea that is going to be a chat pane and would like the chat to appear with different color codings and possibly alternating boldface for time, username, and text. For example,

    [14:09] Psyclone: Insert message here.

    I know other programming languages can pull this off. Can it be done through JTextArea though?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I know of two solutions:

    One, to use JTextArea and HTML code to help with the different colors. -- edit: incorrect!

    The other is to use JEditorPane or JTextPane.

    edit: I'm incorrect about my first suggestion.
    Last edited by Fubarable; 03-27-2010 at 07:57 PM.

  3. #3
    Psyclone is offline Member
    Join Date
    Jan 2010
    Posts
    81
    Rep Power
    0

    Default

    Ahh, yes, now I remember. I read that tutorial a while back, but I think I blurred JTextArea and JTextPane together. I think that's exactly what I need.

    Thanks again.

Similar Threads

  1. JTextArea on PopUp -JTextArea isn't editable
    By Richy76 in forum AWT / Swing
    Replies: 3
    Last Post: 02-01-2010, 08:51 PM
  2. In Case You Want Colors!
    By angryboy in forum Forum Lobby
    Replies: 0
    Last Post: 08-29-2009, 11:06 PM
  3. Colors and shapes.
    By Torgero in forum New To Java
    Replies: 14
    Last Post: 10-13-2008, 06:25 PM
  4. Displaying a Button with Varying Icons
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 08:40 PM
  5. how to set multiple colors in a JtextArea
    By valery in forum AWT / Swing
    Replies: 2
    Last Post: 08-01-2007, 06:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •