gpt4 book ai didi

java - JXTable - 过滤表格后的荧光笔

转载 作者:搜寻专家 更新时间:2023-11-01 03:30:39 27 4
gpt4 key购买 nike

信息 - 为了更好的格式化,我在整个帖子中使用了代码格式化。

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?

最佳答案

你能再添加一个荧光笔吗?

jxTable.getHighlighters().addHighlighter()

只有当 JXtable 被有效过滤时才会应用它自己。

如果那是不可能的,因为一旦一行被高亮显示,其他高亮器可能不会被调用,您可以定义一个 Controller ,它:

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

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

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

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

关于java - JXTable - 过滤表格后的荧光笔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/311175/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com