0

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?

josepmra
  • 617
  • 9
  • 25
  • Some useful caveats are examined [here](http://stackoverflow.com/q/7137786/230513). – trashgod Mar 13 '14 at 12:09
  • for better help sooner post an SSCCE or MCVE or MCTRE, short, runnabloe, compilable with hardcoded value for JTable/XxxTableModel – mKorbel Mar 13 '14 at 12:10
  • if you have a budget, you might consider Synthetica SwingX Addon - it has a variant of JXTable with filter support in the header (note that I'm biased, having developed bothe JX- and JYTable :-) – kleopatra Mar 13 '14 at 17:17

2 Answers2

1

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.

camickr
  • 321,443
  • 19
  • 166
  • 288
0

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

Abhishek Choudhary
  • 8,255
  • 19
  • 69
  • 128