tags:

views:

426

answers:

2

I would like to filter some rows in a JTable but all the stuff google found me is for java 1.6. I would like to do this using java 1.5 since i can not upgrade?

+1  A: 

You should be able to use the SwingX library to accomplish this:

e.g.

Filter[] filterArray = { new PatternFilter("(.*1st.*)|(.*Final.*)", 0, 0) };
FilterPipeline filters = new FilterPipeline(filterArray);
table.setFilters(filters);

There's an article here on this:

http://www.javalobby.org/java/forums/t18819.html

You can chain various filters together using the FilterPipeline and there's a bunch of built in filters that can be used (ShufflerSorter, PatternFilter).

It should provide you with what you need without resorting to a Java 6 upgrade.

Jon
Word of warning - The performance over large datasets is pretty poor in comparison to JDK 6's JTable filtering.
Adamski
A: 

I haven't used them (I'm lucky enough to be using 1.6) but you could try Glazed Lists. It seems to work with 1.5.

KitsuneYMG