Search code examples
jtablecolumnsorting

How to sort unsigned numbers in JTable (JAVA)


Got value of singed number is string. Due this it cannot be sorted as number in JTable. What solution can solve this problem.

Note: I am using custom table model but if the inserted value is string the sorting sorts it as a string regardless of columnclass set.

Integer.toUnsignedString(number);
Class[] types={String.class,String.class,Integer.class,Integer.class};

Maybe there is some solution using TableRowSorter class.


Solution

  • Problem solved via RowSorter and Comparator classes.