hello guys i am still new in java and i have been battling with this problem. i want to filter my data in my jtable.

i have got the following data in my jtable which is from my database.

| name | gender | courses |
|------|--------|---------|
| Ben  | male   | Science |
| Joe  |female  |   I.T   |
| Dan  | Male   | Science |

now i have got combo-boxes name,gender and courses

now i want to filter the table based on these assumptions

"i want all who are studying science"
so then the output becomes

| name |courses|     
|------|-------|      
| Ben  |Science|      
| Dan  |Science|  

"i want all males who are studying science"
so then the output becomes

| name | gender | courses |     
|------|--------|---------|      
| Ben  | male   | Science |      
| Dan  | Male   | Science | 

and so on..... Please any help or direction will be appreciated thanks

depend of how deep you want to go, you have to override RowFilter

___________________________________________________________

  • simple

  • extended

  • there is used JToggleButton for filtering, add Action/ItemListener to JComboBox then result will be the same from JComboBox

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.