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.
Share
Is the problem that you need to provide a sort for your tables the way that
TableRowSorterdid, or that you need to pass the sort key from the parent to the child?If the former, you could back your
JTableswith aTableModels that contain row objects that implementComparable. You can then implement your ownComparatorclasses per column. You can then, in your customTableModelset the appropriateComparatoron your backing sorted Collection.If the latter, I imagine that you are implementing
ListSelectionListenerin 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 currentComparatorand apply that to the child table model.