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
close site for maintenance
i get a tutorial, saying the following code can put our site offline, and only the developer can vie
form class help (oop php5)
Hidy Ho Neighbors,
I'm forcing myself to learn oop/classes for php5. It seems like a good id
Beginner question regarding Array's
Hi everyone, the page im working on has an array of variable at the top...
Code: $define_li
How to display objects in a row
I have 7 codes that i want to display in a row one next to another.
The first is {$ads->ad
form variables from database help.
Hi all,
I would like to have a form that gives you options based on the results of an mysql q
Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and
Session variable help
I'm having a very troubling issue. Maybe I'm just looking over something but I have looked at the co
need help to creat database
Hello Team, please guys i am stuck from three days with paypal issue for IPN but no luck yet now i w
How to kill asynchronous postback / current postback?
Hi,here is my problem:I have a web site with many pages of which some may take time to process resul
order by date not ID number help php
I am trying to orginize the following code to order by date not id number.
any help would be grea