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
Print 'a' to 'z' via for loop
A very simple problem..
How Can I print a to z NOT a to y ?
It is a part of a code where
<
Force download script not handling files with spaces properly
I have a regular old php force download script, uses this code:
Code: header("Cache-Cont
Weird Problem with curl while sending data
I am facing a weird problem with sending data to a site via curl.
If i send the value by this
Php WordPress help
I am writing the following code for making a plugin
<?php
header("Content-Type
Am i doing this wrong?
Im pulling from an Oracle database some info... one of which is a field count_pnums which is a NUMBE
Just wondering what you think about my site
I am new to phpfreaks i just seen this form and thought it would be cool to see what other thought a
PHP XML extraction text
I would like to extract an xml text and have that text directly echo(print) out on my web page. Her
Get relative path from absolute path
How would one go about getting the relative path to a file from its absolute path?
Undefined index: username HELP NEWBIE
I am trying a simple login/logout for my website. It works well with checking if the username exists
Product categories for registration
Dear all,
We are going live with the Supplier registered next week. At standard, the 'sel