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
need help with php get
i have a option box that gets filled with dates, but how do i get once the option value has been cli
firefox wouldnt stream mp3 files completely from my php page
hi everyone,
I have a php file trying to read and stream mp3 files. It works fine in IE but my pr
Pop-up Banner
Hello Friends,I need to use banner in our client site.Example: www.example.com if i enter this site
creating a 1 to 100 in a table
hi guys I am a newb in php need some help.
I have a table with 1 column and 100 rows and in
Running a cron job through PHP/Apache?!
Hello all,
I have a PHP script which makes a cron file from user input. When i try to run the cro
Filling gaps in dates
So i'm doing a query for sales data and my return array looks like this
('date' => '20
How to give the privillege for triggers?
Hi,
How to give the privillage for triggers to particular user?
Please let me
Question about GD library
I am trying to make an image that shows a random quote from my database.
However I want t
help finding hacking loopholes
i was attacked by a redirect php injection
my pc is clean of viruses
so i figure that
How to Handle more than one submit button in single form?
Hi
I have one PHP file which contains one Form. In this form there are two Submit type Buttons