The Artima Developer Community
Sponsored Link

Java Answers Forum
How to change the sepcified string color in a TextArea or JTextArea?

1 reply on 1 page. Most recent reply: Jul 7, 2005 2:48 AM by Antonio

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Mr Wang

Posts: 1
Nickname: whboy
Registered: Mar, 2005

How to change the sepcified string color in a TextArea or JTextArea? Posted: Mar 3, 2005 5:37 AM
Reply to this message Reply
Advertisement
I am doing a document editor program in java.
The problem is that how to change the java keywords color in a TextArea or JTextArea when we inputing characters in the edition-area?

I mean the keywords dispalying in one color,while the not-keywords string displaying in another color.

The following methods obviously don't make it:
void setForeground(Color c)
void setSelectedTextColor(Color c)
void setSelectionColor(Color c)

I am now puzzled.
If can't,can the JEditorPanel or JTextPanel make it?


Antonio

Posts: 33
Nickname: arhak
Registered: Jul, 2005

Re: How to change the sepcified string color in a TextArea or JTextArea? Posted: Jul 7, 2005 2:48 AM
Reply to this message Reply
In fact you can't with TextArea nor JTextArea
and yes, it is possible with JTextPane and JEditorPane
See
http://java.sun.com/docs/books/tutorial/uiswing/components/text.html
there is everything you will need to know

Flat View: This topic has 1 reply on 1 page
Topic: Upcasting Previous Topic   Next Topic Topic: Applet to Applet Communication

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use