This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Can row filters be combined? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Can row filters be combined?" Watch "Can row filters be combined?" New topic
Author

Can row filters be combined?

Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
This may not be possible, but I have tried every iteration I can think of to get this to work. I have one table with eight columns, three of the columns we be filterable. I can get each column to work independent of the others, but I would like to get them to work together, if possible.

The three columns are: Shop, Labor, and Parts. The desire is to allow "Monroe" to be put into Shop, and "muffler" to be put into Parts, and have the table filtered on both values.

Here is my latest attempt at combining them, may give you a better idea of what I am talking about.



It compiles and runs, but it filters only on the last entry (partsFilter)
Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
Ok, I found that there is an andFilter, but I haven't been able to find any examples of how it is coded. I've tried a couple ways, but none of them compile.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

Usually, any "and" returns true if all elements are true and false otherwise. Purely theoretically, if there are no elements that still means that all elements are true.
In the case of RowFilter.andFilter, the "elements" are the return values of the include method of each filter.

If you ever want to look at the source of a Java class, in your JDK folder there is a file called "src.zip". Inside is the source code for most of the core API.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2180
    
    7
I found that there is an andFilter, but I haven't been able to find any examples of how it is coded.


1) Read the JTable API and you will find a link to the Swing tutorial on "How to Use Tables" where you will find a RowFilter example that uses a RegexFilter on a specific colum.

2) Read the RowFilter API for the andFilter() method where you will find and example of how to add multiple filters.

Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
RC, thanks, I had already found that page and worked it out.



The first page I found just showed this:

At least to me saying Iterable doesn't imply ArrayList - confusing as hell.
 
 
subject: Can row filters be combined?