• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with sorting and filtering a JTable

 
John Sutt
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Eugenio Flores
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20559
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you can use DefaultRowSorter's sort() method. TableRowSorter inherits this method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic