4

信息 - 为了更好的格式,我在整个发布过程中使用了代码格式。

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

1 回答 1

2

你能加第二个荧光笔吗?

jxTable.getHighlighters().addHighlighter()

一种仅在有效过滤 JXtable 时才应用的方法。

如果这是不可能的,因为一旦突出显示了一行,可能不会调用其他突出显示,您可以定义一个控制器

a) 对表有一个 propertyChangeListner,监听过滤状态

b)具有带有行集和荧光笔的特殊谓词

c)在 propertyChange 检查行,在 NEVER 和您的自定义之间切换荧光笔的谓词。荧光笔的属性改变会触发重绘

强制重绘基本上是 test.org.jdesktop.swingx.renderer 包中的 HighlighterClientVisualCheck 示例的作用。

于 2008-11-22T10:46:00.047 回答