The basic premise would be to use a custom TableCellRenderer
that provided the functionality that you require.
The problem is how to implement it.
I would create a TableCellRenderer
based on a JTextField
, remove it's border and make it transparent. This will allow you to use the text highlighting functionality provided by JTextCompoent
to highlight portions of the text, as demonstrated here.
The next problem is then knowing what to highlight. There are a number of possibilities.
You could provide a method in your table model that could return the current text that should be highlighted.
I'd, personally, probably use the JTable#putClientProperty
and JTable#getClientProperty
methods to seed the search text.
Or, you could actually provide a simple model that directly to the renderer which had a method that returned the current search text. This might actually be more useful as you could link it to field, the method building the filter and the renderers and allow them to simply seed each other