在Java中单击表行时未调用自定义比较器的Compare方法

在Java中单击表行时未调用自定义比较器的Compare方法,java,swing,jtable,comparator,tablerowsorter,Java,Swing,Jtable,Comparator,Tablerowsorter,我已经创建了自定义comperator来比较第一行的值,但从未调用“compare”方法 tableSorter = new TableRowSorter<TableModel>(myTable.getModel()); tableSorter.addRowSorterListener(this); tableSorter.setComparator(0, new Comparator<MyEntry>() { @Override public int c

我已经创建了自定义comperator来比较第一行的值,但从未调用“compare”方法

tableSorter = new TableRowSorter<TableModel>(myTable.getModel());
tableSorter.addRowSorterListener(this);
tableSorter.setComparator(0, new Comparator<MyEntry>() {
    @Override
    public int compare(MyEntry arg0, MyEntry arg1) {
        return compareMyColumn(arg0,arg1);
    }
    });                           

scanResoultTable.setRowSorter(tableSorter);
tableSorter=newtablerowsorter(myTable.getModel());
tableSorter.addRowSorterListener(本);
tableSorter.setComparator(0,新的Comparator(){
@凌驾
公共整数比较(MyEntry arg0、MyEntry arg1){
返回compareMyColumn(arg0,arg1);
}
});                           
ScanResourceTable.setRowSorter(表排序器);

您如何知道它从未被调用过?出于为什么您需要自己的ComparatorId调用
setSortKeys()
以指示您希望表按列0排序?My列表示名为MyEntry的自定义对象。我必须通过比较这些对象对列进行排序。我通过使我的目标实现可比性来实现这一点。。。