2008-11-22 55 views
4

信息 - 爲了更好的格式化,我在整個過程中使用了代碼格式。JXTable - 過濾表後的熒光筆

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? 

回答

2

您可以添加第二個熒光筆嗎?

jxTable.getHighlighters().addHighlighter() 

時,其中一個JXtable被有效過濾,這將僅適用於本身。

如果這是不可能的,因爲一旦一排已經凸顯,其他熒光筆可以不叫,你可以定義控制器其中:

一)具有propertyChangeListner表,偵聽過濾狀態

b)與行的集合和爲propertyChange熒光筆

三)檢查行,切換NEVER和您的自定義適當的熒光筆的謂詞的特殊述。突出顯示器的屬性更改將觸發重新繪製

強制重繪基本上是在test.org.jdesktop.swingx.renderer軟件包中的HighlighterClientVisualCheck示例。