• Post Reply Bookmark Topic Watch Topic
  • New Topic

setting different text colours  RSS feed

 
james barrett
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

im trying to set different colours for different lines of text in a JTextArea, but the setForeground method changes the entire thing, is there a way to change just one line.

e.g

black text --> hello
green text --> bye
black text --> hello again!

thanks

j
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there isn't. You need to use one of the other similar text components for that.
 
james barrett
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
other text componants? you mean like a textpane and such?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read this tutorial and you will get much more useful information than just the bare answer to your question: Using Text Components.

By the way, I got this link from the API documentation for the JTextArea class. Sun's tutorials are usually worth reading.
 
james barrett
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hehe thanks, i had just stumbled over that now

thanks for the help
j
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a Swing-specific question. Moving.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!