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
PHP and SMS
Hi all forum members. I am new here and am unsure what category shoild I post this in.
Moderator
Show message after entering data
Hello Colleagues
I would like to display messages after entering the data example: "
dat
in php, link returns to the line
When I add a link in a php page, the link word returns to the line (as a
would do)
Examp
captcha error
I have been trying to implement a captcha in php...
here is the code..
Code: (php) [Select
Need help with some php code :)
Hey! I'm quite new to this whole thing, so please don't fire me with shait on this one =D
I'm
sapgui f4 help last search
I know this has to be simople. One user (maybe more) does not have the "last search saved" from the
Solution to the FindControl problem
I have seen may posts about having problems with the FindControl method. Most seem to come about bec
help me fix these syntax errors...
I keep getting multiple syntax errors on this script like this one:
Parse error: syntax error
Multiple upload and Resize
I would like some help on my script I have the for my index.php
////
<html&
RadioButtonList item spacing
I have a RadioButtonList and I can't put any spacing between the items. They are arranged verticall