« Return to Thread: I don't understand how SortedList and TableComparatorChooser work together

I don't understand how SortedList and TableComparatorChooser work together

by Boomah :: Rate this Message:

Reply to Author | View in Thread

Hi people. I don't understand how SortedList and TableComparatorChooser work together.

I have objects that get added to a SortedList that represent (via my TableFormat) a row in a table. The SortedList uses this object to sort, and if I just use a standard JTable, whenever an object is added to my list, it gets added to my table in the appropriate position. Everything works exactly as I would expect.

Now I install a TableComparatorChooser on my JTable. If I start my application, I see items being added to the table in the correct position given my SortedList as before. However, if I now click on one of the columns, it sorts not using my SortedList but by using the objects in the column I clicked on. In my case they are all strings and so get sorted using the standard string comparator.

I don't understand why the TableComparatorChooser requires a SortedList if once the user clicks on a column, it gets sorted by the objects it contains. Why isn't it possible to use an EventList?

It feels like I'm missing something obvious, but I think that SortedList and TableComparatorChooser completely work against each other and should be separated.

Have I completely missed the point?

Thanks, Nick.

 « Return to Thread: I don't understand how SortedList and TableComparatorChooser work together