I want to filter a jtable using columns that are in a background array but not shown in the table. What I want to do is score each row, sort the array on the basis of the score and then display the result in a table.
I followed the sorting / filtering tutorial and can display the table and filter it using the columns showing in the table but when I try to write my own sorter using the columns in the array behind it I can't find a way that compiles.
Partno, Description, Size
Array (of type product)
Partno, Description, Size, notes, longdescription, score
The user enters a string in a text field and that causes a loop through the array updating the score depending on whether it found the string and in which column. I then want to filter the table with only those that have a score > 0 showing and sort them by score.
I have come across a tutorial which says wrap the array in a model but when I do this I get an error saying "Type argument prodmgr.ProductModel is not within bounds of type variable M" I cannot understand this error message (where did it get M from?) and looking for this I can find no example that is similar.
I am using Netbeans (in case that changes anything), this show a rowsorter attribute in the table definition, would there be a way to put some custom code in here to make it sort on a field in the array?
I was loading them into a DefaultTableModel and then setting the JTable model to that. I've now created a ProductModel class but I'm not sure it's helping. Since I did this I haven't been able to compile it. What I'm doing now is taking the filtertabledemo from the Java tutorial and building on that hoping that it will give me some way of tying it back to the array? I don't think it will do it. An alternative would be to have all of the columns in the table array but not show some of them; is that possible?