Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TableSorter problem

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I implemented sorting example on sun's website: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html . However, there is problem with this code. As I understand TableSorter acts as a shell for my current TableModel, so when I sort JTable is makes changes to TableSorter and TableMap classes but not the TableModel that I use. What should I do so that when I sort JTable, the original TableModel changes as well?
thanks,
Alex
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The benefit of this technique is that allows you to use models that are not sortable. TableSorter is a generic sorter that can be applied to any table.
If you really want to sort the model, do not use a wrapper for the model . Just use a model that knows how to sort its data. For instance via the Collections.sort(...) methods, or SortedSet/Map types.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic