aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes TableSorter problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "TableSorter problem" Watch "TableSorter problem" New topic
Author

TableSorter problem

Alex Kravets
Ranch Hand

Joined: Jan 24, 2001
Posts: 476
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


All right brain, you don't like me and I don't like you, but let's just do this one thing so I can get back to killing you with beer.<br /> <br />- Homer Simpson
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
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.


SCJP2. Please Indent your code using UBB Code
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TableSorter problem