Is there a way where I can have a parent JTable sort value be passed and set the sort of a child JTable in Java 1.4? What I have is a parent JTable of subjects with about 6 columns and a child JTable that is a subset of the parent JTable with the same columns. What I need to do is when the user selects a item from the parent JTable and updates the child JTable, the sort is changed to whatever the parent JTable is at that time. I had this working fine with Java 1.6 with开发者_高级运维 the TableRowSorter class until I realized I had to use Java 1.4 - which the TableRowSorter class is non-existent.
Is the problem that you need to provide a sort for your tables the way that TableRowSorter
did, or that you need to pass the sort key from the parent to the child?
If the former, you could back your JTables
with a TableModel
s that contain row objects that implement Comparable
. You can then implement your own Comparator
classes per column. You can then, in your custom TableModel
set the appropriate Comparator
on your backing sorted Collection.
If the latter, I imagine that you are implementing ListSelectionListener
in order to trigger the population of the child table with the correct data. In this same process you can query the parent table for its current Comparator
and apply that to the child table model.
精彩评论