josepmra
josepmra

Reputation: 627

using row to filter Jtable in Swing

I want to filter the content of my Jtable with different Textfields in a header row but I don't know how do it.

My idea is use TextField as cell editor for the first Row (the unique editable row of my table). My first problem is that don't know how define this row with a setCellEditor method, I think this method only serves to define the column editor object.

Any idea as how do it?

Then I belive that I will have other problem: How do I order my table without lose my filter row?

Upvotes: 0

Views: 722

Answers (2)

camickr
camickr

Reputation: 324098

How do I order my table without lose my filter row?

Don't use data in the table as a filter row.

Instead create separate text fields above the table to use as the fllter. Read the section from the Swing tutorial of Sorting and Filtering for a working example.

Upvotes: 1

Abhishek Choudhary
Abhishek Choudhary

Reputation: 8385

Filtering if you mean to show Table data based on keywords enter in the JTextfield based header, then you can simply work with Table Model to achieve the same.

if you want to sort the content , use Sorter for the same. http://www.java2s.com/Code/Java/Swing-JFC/JTablesorterclickthetableheadertosortacolumnandatable.htm

Upvotes: 0

Related Questions