Sorting JTable on more than just the values listed in the columns


Posted on 16th Feb 2014 07:03 pm by admin

I have a collection of objects that store (among other things) two integer values. I only want to display one of these values. The displayed value will dictate the sort order of the JTable.

However, I want to break ties with the other, undisplayed, integer value.

Did you know?Explore Trending and Topic pages for more stories like this.
I've gone through the trouble of specifying my own Comparator for the TableRowSorter. However, this method doesn't have access to the row index into the table. It is only passed the values in the column that is being sorted, not their position in the column. Without having a reference back to the row index (which I use as an index to the collection of objects) I cannot get the secondary value, unless I also display this value in its own column and sort on Sort Keys.

I don't want to do that, because I feel it clutters up the look of the table.


For example, I have the two sets of numbers

Row Name | Displayed Value | Undisplayed Value
rowA | 7 | 3
rowB | 7 | 5

With this set of data, rowB should be listed above rowA. Any ideas on how to implement this.

I'm pretty new to Swing, so there could be something simple that I'm missing (hopefully).
No comments posted yet

Your Answer:

Login to answer
296 Like 12 Dislike
Previous forums Next forums
Other forums

question about stripslashes and real_escape_string
im cleaning up an old app that I wrote fixing some of the vulernabilities from attacks.

I hav

Getting the full city list from maxminds geoip database
I am suprised I can't find any references to this.

I have maxminds geoip lite installed and i

Undefined index on my form
ok im getting Undefined index on this line.. print_r($_REQUEST['form']);

below is the full sc

regex for quoted text within a string
I am still getting the hang of regex expressions, but I cant seem to figure out how I would escape q

calendar dates and hours compare problem
i have a calendar in wordpress, everything works great except that i can make 2 meetings at the same

PHP and XML image gallery variable issue
I'm trying to display the large image on the same page as the thumbnails, to do that I'm passing a v

Trouble with a select list
Hello All!
I was wondering if any of you guys could help me with a small problem I'm having!

values not being entered into table
hi. I;ve created a form, so that when a user enters data into it, it gets added to a table in a data

How to refresh a parent page from a modal popup
Hi,I have a modal popup in which I need to upload a file and store in the database should give a mes

Need PHP help... have all the elements... just need help putting them together :
Hey Guys,

I was wondering if someone could help me. I am doing a website for a client which

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash