Jon Swanson wrote:No such luck, the code for TableRowSorter does not use the custom comparator for null fields.
I'm afraid I'm no GUI expert, but that does make sense to me; otherwise you're likely to get NPE's cropping up in deeply embedded code.
I guess my question is: why are these rows (or column fields) null?
Isn't it funny how there's always time and money enough to do it WRONG?
Joined: Oct 10, 2011
Sorting the rows was added as a requirement after I finished coding something up that allowed a user to interactively enter data into a table. I originally set things up display a table with the number of rows that were likely to be needed. Then, if the user needed more, they could add (or delete) rows from a popup menu. So there will typically be at least one empty row for adding the next piece of data.
I also notice once TableRowSorter is active, it sorts automatically when I add a row, which is not quite what the user is expecting (i.e. they might want to insert a row, enter data, then sort). So there are a few other tricks I may need to learn about TableRowSorter. I'm also looking to have the table initially display in 'sort' mode as if the user had clicked on the table header. I think that might be doable, still experimenting on that.