Results 1 to 3 of 3
  1. #1
    valery is offline Member
    Join Date
    Jul 2007
    Posts
    32
    Rep Power
    0

    Default how to set multiple colors in a JtextArea

    I want to color certain keywords as the users are typing.
    but I don't know how to use multiple colors in a JTextarea.
    Do you have any idea ?

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Yes. JTextArea supports only a single foreground color, background color and font. To Have more than this you can work with a StyledDocument in a JTextPane.
    For discussion and example code see How to Use Editor Panes and Text Panes, especially the section An Example of Using a Text Pane.

  3. #3
    valery is offline Member
    Join Date
    Jul 2007
    Posts
    32
    Rep Power
    0

Similar Threads

  1. How to add a shortcut key from JTextArea
    By sukatoa in forum Advanced Java
    Replies: 2
    Last Post: 01-28-2008, 08:39 AM
  2. JTextArea
    By saytri in forum New To Java
    Replies: 0
    Last Post: 01-13-2008, 01:07 AM
  3. change colors
    By calblue in forum New To Java
    Replies: 1
    Last Post: 12-02-2007, 11:52 PM
  4. Jtextarea and scroll
    By ziniestro in forum AWT / Swing
    Replies: 2
    Last Post: 06-01-2007, 03:59 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
  •