• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Highlighting search word in JList

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a JList which shows file data. I have provided with the search facility through which user can search in through the file. JList provides a function 'getNextMatch(String prefix, int startIndex, Position.Bias bias)' to search, however this function only searches for those words which are complete, and not substrings. What I can do is provide a similar functionality by implementing my own search function, but I am not getting how to highlight the searched word in the list.

Can anybody please help.

Thanks
Devang Shah
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what ListCellRenderers are for.

The javadoc for JList gives an example of this, though I'm not wild about it. I think it would be better to extend DefaultListCellRenderer.
reply
    Bookmark Topic Watch Topic
  • New Topic