wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JTable rowFilter - is case insensitive possible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable rowFilter - is case insensitive possible?" Watch "JTable rowFilter - is case insensitive possible?" New topic
Author

JTable rowFilter - is case insensitive possible?

Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
I tried inserting a RowFilter into my table and it worked, so long as the filter argument matched the case in the column.



This successfully returned the rows containing "Alternator" in the Parts column. But, if I change the filter to "alt" then I do not get a hit. I tried entering Pattern.CASE_INSENSITIVE into the filter (see below), it compiles but when I execute the code no rows are returned. I checked the Java documentation on RowFilter, and there is nothing about how to set expression flags. I also tried replacing "alt" with a pattern, but that wouldn't compile.



Patrick Elliot
Greenhorn

Joined: Jun 04, 2010
Posts: 1


Putting (?i) at the start of the regex makes it case insensitive.

Dirty little trick, but it works.
Mike Lipay
Ranch Hand

Joined: Sep 11, 2007
Posts: 171
Most excellent! Thanks.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

Patrick Elliot wrote:

Which of course is simply "(?i)Alt"

Dirty little trick, but it works.

Nothing dirty about it, it's even mentioned in the Javadoc of Pattern's CASE_SENSITIVE field:
Case-insensitive matching can also be enabled via the embedded flag expression (?i).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: JTable rowFilter - is case insensitive possible?
 
Similar Threads
Problem with filtering JTable (AbstractTableModel)
Problem with sorting and filtering a JTable
Can row filters be combined?
JTable adding a RowFilter can no longer add to the table get invalid range?
RowFilter dont show rows in JTable