aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Problem with sorting and filtering a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem with sorting and filtering a JTable" Watch "Problem with sorting and filtering a JTable" New topic
Author

Problem with sorting and filtering a JTable

John Sutt
Ranch Hand

Joined: Mar 07, 2008
Posts: 42
Dear Ranchers,

I have extended JTable with a table class that makes use of both a rowsorter (CustomTableSorter) as well
as a custom row filter (CustomRowFilter).
The problem I'm having is that, if the filter is changed (other rows are being displayed, more or less rows possible),
the sorting should be re-done.

I know the tableChanged method is called after the filter is changed - I verified this.
However, although setRowSorter(sorter) below is also executed, the sorting is often still not correct.

I guess I have to do more to make the JTable re-do its sorting (using the installed row sorter),
but what method should I call for that?

Thanks for any help.



SCJP 6 (91%), SCJD (91%)
Eugenio Flores
Ranch Hand

Joined: Sep 13, 2007
Posts: 38
Why don't you use a JXTable, is a table where you use ordering at runtime.

Visit http://swinglabs.org/


Greetings
John Sutt
Ranch Hand

Joined: Mar 07, 2008
Posts: 42
Hi Eugenio,

Thanks for your reply.
I will certainly have a look at it, maybe I can find out how to do it by looking at its source.

It's for learning purposes though, so I'd like to figure out how to get it working by only using
JTable.

John.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Perhaps you can use DefaultRowSorter's sort() method. TableRowSorter inherits this method.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with sorting and filtering a JTable