Link to home
Start Free TrialLog in
Avatar of gdkinney_2
gdkinney_2

asked on

Need to sort a JTable column correctly in Java 1.6. So that "2" comes before "16" when I sort the column in ascending order.

Need to be able to sort a JTable column correctly in Java 1.6.  For example so that "2" comes before "16" when I sort the column in ascending order.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of contactkarthi
contactkarthi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gdkinney_2
gdkinney_2

ASKER

Actually I need to sort my rows in a JTable when a user clicks on the heading for a column in my JTable.  So all rows will be sorted (ascending or descending) based on the data in the clicked column.
can you post the code soit will be easy for me to point out where to change
>>For example so that "2" comes before "16" when I sort the column in ascending order

if the values are integer/numeric pass them as approprite object type rather String. for e.g., if it is integer, new Integer( 2 ) instead of "2"!
also make sure the column class returned appropriately by the model. for e.g., for int, return Integer.class
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial