Skip to main content

TableRowSorter: I'd like to have a way to override the default Comparator

No replies
Joined: 2003-06-11
Points: 0

Specifically I'd like to not use a simple Collator for String columns that have no explicit Comparator set.
Instead I want to use a "natural sort" honoring contained numbers see:

TabeRowSorter makes it much too hard to do this:
TableRowSorter.getComparator() calls super.getComparator() to check if a Comparator has been set to a fixed value.
Now if I override getComparator() in a subclass: How can I test if a Comparator has been explicitly set?

To solve this problem, you could either add a method "boolean isComparatorSet(int columnIndex)" or else a method "Comparator getDefaultComparator()" that is used if no comparator has been set (so that I can override only that part).

Any chance to get this?