here is the thing, if you are looking for syntaxic filtering this functionality already exists in java as TableRowSorter which can be combined with row filter to set the subList and show it.
display in JTable part of a collection [duplicate]
-
20-09-2022 - |
Question
I have created a JTable using AbstractTableModel in which I added a collection of objects (ArrayList). I want to be able to search through the objects and return in the same JTable only the ones that meet a conditions (for example the names starts with "St"). Theoretically, how can I do that? Do I have to make new ArrayLists for every condition, and store these searched (and returned) objects there? Is there a better/simpler way? Thanks
Solution 2
OTHER TIPS
As shown here, you can access a Collection
in your implementation of AbstractTableModel
. As shown here, you can sort and filter the results without modifying the original data structure. A complete example is examined here.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow