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

JTable - Enable filtering but disable sorting

Payam Fard
Ranch Hand

Joined: Jan 31, 2003
Posts: 73
Hi all,

I have a jtable for which I would like to have filtering capabilities but disable sorting. Right now, I can filter the values shown in the table but user can also click on the table header to sort the values. How I can disable sorting while keeping the filtering?

Thanks.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4638
    
    5

To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.

Also, read the API for DefaultRowSorter -- there's a method that determines whether each column is sortable.


luck, db
There are no new questions, but there may be new answers.
Payam Fard
Ranch Hand

Joined: Jan 31, 2003
Posts: 73
How can I disable sorting on the following code while keeping the filtering?

http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/components/TableFilterDemoProject/src/components/TableFilterDemo.java

Thanks.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4638
    
    5

1. Where's that SSCCE?
2. How many methods are declared in the DefaultRowSorter class?
3. Of those, how many are mutators?
4. What does each of those mutators set?
Kelly Nichols
Greenhorn

Joined: Aug 23, 2012
Posts: 1
Did you figure out how to solve this problem? I too would like to filter out some rows, but not have the table sorted when you click the header. I was thinking about resorting to a glass pane over the headers.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4638
    
    5

The answer to this one is still the same:
Darryl Burke wrote:... read the API for DefaultRowSorter -- there's a method that determines whether each column is sortable.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable - Enable filtering but disable sorting