Pregunta

Información: para un mejor formato, utilicé el formato de código en toda la publicación.

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?
¿Fue útil?

Solución

¿Podría agregar un segundo marcador?

jxTable.getHighlighters().addHighlighter()

Uno que solo se aplicaría cuando JXtable se filtre efectivamente.

Si eso no es posible, porque una vez que se ha resaltado una fila, es posible que no se llame a los otros marcadores, puede definir un controlador que:

a) tiene una propiedadChangeListner para la tabla, escuchando el estado filtrado

b) tiene el predicado especial con el conjunto de filas y el marcador

c) en propertyChange verifique la fila, alterne el predicado del resaltador entre NUNCA y su personalizado según corresponda. El cambio de propiedad del resaltador activará el repintado

Forzar un repintado es básicamente lo que muestra la muestra HighlighterClientVisualCheck en el paquete test.org.jdesktop.swingx.renderer.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top