revo
revo

Reputation: 538

Use JTable rowFilter for highliting rows

I am currenlty using the JTable rowFilter for filtering my rows. The filter hide lines which does not follow the configured pattern. I wish to know if it's possible to use the rowFilter for changing the color or other of the result ? By example the line which follows the configured pattern are colored in red and other in white.

Thank you Sylvain

Upvotes: 1

Views: 929

Answers (3)

mKorbel
mKorbel

Reputation: 109813

Nothing complicated. For String Instance, I would suggest to start with prepareRenderer. There you can set lots of parameters, as shown in RowFilter example here based on camickr's Table Row Rendering :-) Don't forget to set int modelRow = convertRowIndexToModel(row);

and my question about similair issue

Upvotes: 3

Thomas
Thomas

Reputation: 88717

In order to change the appearance of a row you'd need to provide your own cell renderer which then could apply the same checks as your row filter.

Upvotes: 0

crusam
crusam

Reputation: 6178

For those approaches I would recommend using SwingX Libraries. Their JXTable can by default work with highlighter- and filterpipelines. The highlighter can also highlight by a given pattern.

Here an example from R.J. Lorimer

Upvotes: 1

Related Questions