Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Highlighting search word in JList  RSS feed

 
Shah Devang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
Brian Cole
Author
Ranch Hand
Posts: 949
1
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!