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
12
Other forums
Procedural to OOP
John Kleijn said that to avoid writing "crappy code", we should learn OOP and common OO pr
Using CSS to format MySQL query
Hi,
If i want to have a news page on my site, which displays all records of a table in descen
Removing Title From database problem
Hi again ! i am having an issue with updating database. When i update any price of a title it remove
Get relative path from absolute path
How would one go about getting the relative path to a file from its absolute path?
Email/MMS to Site
Hey guys. I'm looking for a way for a user to upload images and/or text via their cell phones. It
noob question
i traying to do a php form with auto replay for both(me and the user who send me a mail),
a u
php problem?
I don't think I'm stupid, but maybe I am.
I am working on a sit for a friend I am try to put
Multi image upload
I have a gallery to build and want to build a dynamic upload form to allow for $var number of fields
Php If in MySql query (hiding labels if a field is empty)
Okay, I've been trying to do this for a while, and I'm finally going to ask for help so I can get th
What's wrong with my code
sobbing for many days, still don't know why please Help. Why my page isn't posted correctly. In a