I Have a JTable which i I need to resort the rows when a new row is added automatically.
But the Table cannot be allowed to have the sorting functionality by clicking the header active.
Normally when i load the table for the first time i can sort the rows by sorting the list of the data before hand.
Comparator<Map.Entry<FieldDescriptor, Object>> c = new Comparator<Map.Entry<FieldDescriptor, Object>>() {
public int compare(Map.Entry<FieldDescriptor, Object> o1, Map.Entry<FieldDescriptor, Object> o2) {
return o1.getKey().getName().compareTo(o2.getKey().getName());
}
};
List<Map.Entry<FieldDescriptor, Object>> lSet = eSet.stream().collect(Collectors.toList());
Collections.sort(lSet, c);
And this works fine because when i add the rows to the table for the first time, because the list is already sorted, and they come on the correct order.
But if a new row is added afther the table is filled i need to reorder the rows correctly.