JXTable - Highlighter after filter table

Information - for better formatting, I used code formatting throughout the publication.

Hi, I have a highlighted JXTable. Rows are highlighted, depending on the value of a specific column (c2). Everytime the value of column c2 changes, the color is switched from white to grey or from grey to white. Example c0 c1 c2 c3 1 | aaa | ab | dd 2 | aaa | ab | ee 3 | aaa | cd | ff 4 | aaa | cd | gg 5 | bbb | ef | dd Colors are like this: 1,2 -> white 3,4 -> grey 5 -> white If I now filter for 'dd', my table looks like this c0 c1 c2 c3 1 | aaa | ab | dd 5 | bbb | ef | dd And the colors are like this: 1 -> white 5 -> white But I want the table to change the color of row 5, because the previous value in c2 was different. See my Problem? How can I apply the highlighter again, on my JXTAble, after filtering? Or in other words, how can I highlight only the filtered values? 
+4
source share
1 answer

Could you add a second marker?

 jxTable.getHighlighters().addHighlighter() 

One that will only be applied when the JXtable is effectively filtered.

If this is not possible, because once the line has been highlighted, the other callers cannot be called, you can define a controller that:

a) has aChangeListner property for a table, listening for filtered state

b) has a special predicate with a rowset and marker

c) on propertyChange, check the line, switch the marker predicate from NEVER and your custom one, if necessary. Changing a shortcut property will cause a redraw

Forcing redrawing is basically a sample of the HighlighterClientVisualCheck in the test.org.jdesktop.swingx.renderer package.

+2
source

All Articles