• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to combine groups of filters for a TableModel using setRowFilter  RSS feed

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys.

I have a tablemodel of five columns then I need to apply filters in this order. First I need to filter TAXI in column 0 then to filter OBS in column 2 and finally STATUS in column 3.

I have tree groups of buttons on three JPanels and tree groups of variables for those three JPanels.

Inside every JPanel there is an orFilter:

for TaxiPanel :
column0
filtersTaxi=(TAXI01 or TAXI02 or TAXI03 or TAXI04 or TAXI05 or TAXI06)

for ObsPanel :
column2
filtersObs=(Confort or Mechanical)

for StatusPanel :
column3
filtersStatus=(Process or Finished)
      
So what I'm trying to get is a something like this:

            totalFiltered=(totalFilteredTaxi && totalFilteredObs && totalFilteredStatus)

  

But I can't find a way.

I've been progressing with your help I hope you can help me again.
 
joe encalada
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code working but not combined.

 
Rancher
Posts: 2934
19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all post a proper SSCCE when asking a code. The reason your last question had 18 replies is because you didn't simplify the code or question.

Your question is about using a filter so there is absolutely no need to post 500 lines of code. All you need is a JFrame with a JTable and some data in the table. A SSCCE can be created in about 20-30 lines of code.

Read the section from the Swing tutorial on Sorting and Filtering for the basics and simple code to learn from.

The following code is modified from the TableFilterDemo and shows how to use the "RowFilter.andFilter(...)".



Change the demo code to get it working. Then once you understand the basics you can fix your real code.

 
joe encalada
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found a solution creating these to variables to make the AND filtering:

so that from the code I posted:
First group of filters:

Second group of filters:

Third group of filters:

I hope it can help to others.

Rob. Thanks for your suggestions.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!