• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Highlighting Words in a String

 
Muhammad Ahsan Jamshaid
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all..
i am making a search function... now i can find the word in a string but i want the finded word to be shown highlighted (in a tree or TextFeild) . Is there any thing that make a String in which some specific words are highlighted or Bold or Color not the whole string... The return type remains a string....

Or any other suggestion to do it......

--Ahsan Jamshaid..
 
Petrus Pelser
Ranch Hand
Posts: 132
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at javax.swing.text.JTextComponent

setSelectionStart(),
setSelectionEnd(), and
setSelectionColor().

You select the text and then change its colour.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic