my dog learned polymorphism*
The moose likes Beginning Java and the fly likes Highlighting Words in a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Highlighting Words in a String" Watch "Highlighting Words in a String" New topic
Author

Highlighting Words in a String

Muhammad Ahsan Jamshaid
Ranch Hand

Joined: Jun 01, 2006
Posts: 59
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..


--Ahsan Jamshaid... SCJP 5(80%)
Petrus Pelser
Ranch Hand

Joined: Feb 20, 2006
Posts: 132
Take a look at javax.swing.text.JTextComponent

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

You select the text and then change its colour.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Highlighting Words in a String