use sortKeys AND custom comparator – JTable

After you create a TableRowSorter, you need to install your custom comparator first, before setting sort key list. Reversing the sequence breaks the correct behaviour, but I don’t know why.

If you use sort key list (like sort first by quote price, Then timestamp), you may want to keep the live table sorted that way forever. You need to disable mouse-click-sort on Any columns. Here’s one way to do it —

public final void toggleSortOrder(int column) {}//disabled

Mouse events are still generated, but when the event handler calls into toggleSortOrder() nothing happens.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s