3

I'm trying myself developing a desktop application with Java and Java Swing. Currently I'm implementing a property table where can I handle different types of properties of an object. For that I created a custom table model.

However I got some problems adding a filter ability which shows only properties matching a given string.

I found a neat library called swingx which provides many functions I need, like filtering.

This tutorial (http://www.javalobby.org/java/forums/t18819.html) shows examples of how to implement it in JXTable but it won't work. Seems that swingx-1.6 kicked out the setFilter-method().

Any ideas?

Filter[] filterArray = { new PatternFilter("(.*1st.*)|(.*Final.*)", 0, 0) };
        FilterPipeline filters = new FilterPipeline(filterArray);
        table.setFilters(filters);
uriel
  • 167
  • 8
  • that's api in swingx 1.0 (for jdk 1.5). Current version (1.6.2) uses (enhanced, though) core sorting/filtering mechanism – kleopatra Nov 21 '11 at 13:37

1 Answers1

4

JTable supports filtering. See the section from the Swing tutorial on Sorting and Filtering for a working example.

camickr
  • 321,443
  • 19
  • 166
  • 288
  • Well, I found it out myself. Have had some problems with sorting my table and then deleting rows because it won't sort the model but only the view. So I thought with swingx it would be easier. Conveniently the table provides functions like convertColumnIndexToModel(row) to get the right indexes. So I can use the RowSorter and add some filters. – uriel Oct 20 '11 at 13:01