In JTable
, all the columns can be sorted by using Table.setAutoCreateRowSorter(true);
method. But the sorting is not properly in one column in that table which contains cell renderer. If you have any idea about it, please reply.
Asked
Active
Viewed 739 times
-1

Andrew Thompson
- 168,117
- 40
- 217
- 433

user3682281
- 15
- 4
-
41) For better help sooner, post an [MCVE](http://www.stackoverflow/mcve) (Minimal, Complete, Verifiable Example). 2) *"please reply as quick as possible"* For the 100% attention of someone, hire a consultant. For SO, be patient. – Andrew Thompson Jul 15 '14 at 10:20
-
2Before you post anymore questions, please carefully/thoroughly read **1.** [How to Ask](http://stackoverflow.com/help/how-to-ask). **2.** [Writing the Perfect Question](http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx) **3.** [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Also if you want some valid help on _this_ post, edit it and implement what you have learned from reading those links. – Paul Samsotha Jul 15 '14 at 10:43
-
The data in the table model is used to provide the bases for sorting. If to data is modified in anyway, it could produce incorrect results. If the data is displayed differently from how that data is stored/represented, this could produce undesirable results. You may need to consider providing your own sorter – MadProgrammer Jul 17 '14 at 05:00
1 Answers
3
If you use a custom renderer to display the data then you also need to create a custom Comparator
to sort the data in that column.
Read the section from the Swing tutorial on Sorting and Filtering for an example of a Comparator that you can set on the TableRowSorter
.

camickr
- 321,443
- 19
- 166
- 288