File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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: 19216

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


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Problem with sorting and filtering a JTable
 
Similar Threads
JTable refreshment -- or was that 7up?
JTable adding a RowFilter can no longer add to the table get invalid range?
JTable question....again!
JTable rowFilter - is case insensitive possible?
get changed values from JTable