Sunday, June 19, 2011

A Note to myself - JTable.setRowSorter(null)

Never, ever use a line of code from a random forum without completely knowing what it can do to your code. I happened to use JTable.setRowSorter(null)
because I wanted to prevent users from clicking the column header and accidentally sorting the row. While I did that, I didn't know that it would actually end up disabling all the filters I might add later. Murphy's law - it did exactly the same and I wasted hours trying to figure out why aren't my filters working when the sorters are returning correct values. Google doesn't really help a lot when it comes to debugging your code. Unfortunately, I did not mention disabling the rowsorter in the changelist when I committed the changes. Thanks to my memory though, it reminded me of that as a possibility and after removing that line of code, everything is golden!

No comments:

Post a Comment