简体   繁体   English

使用 JTable rowFilter 高亮行

[英]Use JTable rowFilter for highliting rows

I am currenlty using the JTable rowFilter for filtering my rows.我正在使用 JTable rowFilter 过滤我的行。 The filter hide lines which does not follow the configured pattern.过滤器隐藏不遵循配置模式的行。 I wish to know if it's possible to use the rowFilter for changing the color or other of the result?我想知道是否可以使用 rowFilter 来更改颜色或其他结果? By example the line which follows the configured pattern are colored in red and other in white.例如,遵循配置模式的线被着色为红色,其他为白色。

Thank you Sylvain谢谢西尔万

Nothing complicated.没什么复杂的。 For String Instance , I would suggest to start with prepareRenderer .对于String Instance ,我建议从prepareRenderer开始。 There you can set lots of parameters, as shown in RowFilter example here based on camickr's Table Row Rendering :-) Don't forget to set int modelRow = convertRowIndexToModel(row);在那里你可以设置很多参数,如基于 camickr 的Table Row RenderingRowFilter示例所示:-) 不要忘记设置int modelRow = convertRowIndexToModel(row);

and my question about similair issue和我关于类似问题的问题

For those approaches I would recommend using SwingX Libraries.对于这些方法,我建议使用 SwingX 库。 Their JXTable can by default work with highlighter- and filterpipelines.默认情况下,它们的 JXTable 可以与荧光笔和过滤器管道一起使用。 The highlighter can also highlight by a given pattern.荧光笔也可以通过给定的图案突出显示。

Here an example from R.J.这是来自R.J 的示例。 Lorimer洛里默

In order to change the appearance of a row you'd need to provide your own cell renderer which then could apply the same checks as your row filter.为了更改行的外观,您需要提供自己的单元格渲染器,然后可以应用与行过滤器相同的检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM