Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to display different color text in textarea  RSS feed

 
rose deng
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I'm now coding a chat applet,for some reason,i will not use Swing package. I use textarea to display message,what i want to do is display different color text in textarea.I have no idea about how to do it.
Please give me some hint.
thank you in advance.
 
Scott Pedigo
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the setForeground() (and setBackground()) methods.
There are some standard colors you can use which are static in class Color.
Example:
TextField myText = new TextField();
myText.setForeground(Color.red);
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rose,
Scott answer will just change all the text to some color. I believe that is not what you are asking for. You probably want to be able to have some blue text and some red text and maybe some green...
I don't think you can do that with AWT components because they are drawn by the native operating system.
Sorry,
Manfred.
 
rose deng
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes,i know it's difficult task.
other people have some solution about this,please tell me.
thanks n times.
 
deekasha gunwant
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi rose,
no TextArea does not support multiple colors.and because of plugin download time u can't use swing.
in such a case u'll have to do something on your own.
here is a link that can give you some direction
http://www.javaranch.com/ubb/Forum2/HTML/000513.html
regards
deeksha
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!